30 pts.
 Inner join Solution
i write the following Query to execute against the 1500000 in SQL Server 2000 DECLARE Cur_Prefix CURSOR FOR SELECT PrefixNo,PrefixLen,AfterPrefixLen FROM NoSeriesMaster_Prefix WHERE PrefixType='SMS' order by ID OPEN Cur_Prefix FETCH NEXT FROM Cur_Prefix INTO @PrefixNo,@PrefixLen,@AfterPrefixLen WHILE @@FETCH_STATUS = 0 BEGIN SET @SQLStatement = 'update '+@TABLE+' set AuditData.TATCallType=''12'', AuditData.TATCallUnit=''1'' ' + 'from '+@TABLE+' AuditData '+ 'inner join AuditMaster am on am.ID=AuditData.AuditMaster_ID '+ 'inner join HomeCircleMaster hcm on hcm.Ori_CircleMaster_ID=am.CircleMaster_ID and hcm.Ori_ServiceTypeMaster_ID=1 and hcm.Dest_ServiceTypeMaster_ID=1 '+ 'inner join AuditTaggingMaster atm on atm.AuditMaster_ID=am.ID '+ 'inner join NoSeriesMaster ns on (ns.CircleMaster_ID=am.CircleMaster_ID or ns.CircleMaster_ID=hcm.Dest_CircleMaster_ID) '+ ' and ns.ProviderMaster_ID=am.ProviderMaster_ID '+ ' and ns.ServiceTypeMaster_ID=1 '+ 'inner join ProviderMaster_CallTypeMaster pm_ctm on pm_ctm.ProviderMaster_ID=am.ProviderMaster_ID and pm_ctm.CallTypeMaster_ID=101 and pm_ctm.CallTypeTagValue=AuditData.CallTypeTag '+ 'where AuditData.TATCallType is null and substring(AuditData.CallTo,1,convert(int,'+@PrefixLen+'))='''+ @PrefixNo + ''' and len(AuditData.CallTo)='+convert(varchar(10),convert(int,@PrefixLen)+convert(int,@AfterPrefixLen))+' and '''+@PrefixNo+'''+ns.NoSeries=Left(AuditData.CallTo,len(ns.NoSeries)+convert(int,'+@PrefixLen+')) and AuditData.AuditMaster_ID='+@AuditMasterID+' ' print(@SQLStatement) exec(@SQLStatement) FETCH NEXT FROM Cur_Prefix INTO @PrefixNo,@PrefixLen,@AfterPrefixLen END CLOSE Cur_Prefix DEALLOCATE Cur_Prefix the above Query take about 1 hrs to execute against 1500000 is any modification is require in the inner join plz help me its urgent

Software/Hardware used:
ASKED: July 11, 2009  2:51 PM
UPDATED: July 29, 2009  3:10 PM

Answer Wiki:
Hi - Are the columns involved in the join indexed? What is the cardinality of these columns (are they unique)? Do you have current statistics on these tables? Have you explained the access path for this statement? EXPLAIN will give you lots of information about how the data is being accessed and with that you can probably improve the performance of this statement. Good luck.
Last Wiki Answer Submitted:  July 29, 2009  3:10 pm  by  Meandyou   5,205 pts.
All Answer Wiki Contributors:  Meandyou   5,205 pts.
To see all answers submitted to the Answer Wiki: View Answer History.


Discuss This Question:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _