Dear Team,
Could you please suggest me why the below query takes more time to run and How do I improve the performance on the same.
WHILE EXISTS( SELECT Top 1 1 FROM #tempPolicyData) BEGIN DECLARE @AccountNumber NVARCHAR(50) SELECT TOP 1 @AccountNumber =AccountNumber FROM #tempPolicyData IF Exists( Select Top 1 1 FROM [dbo].[CheckRecords] where DetailRecord like '% ' + @AccountNumber +' %') BEGIN SELECT * FROM #tempPolicyData INTO #tempImpactedPolicyData where AccountNumber = @AccountNumberENDDelete FROM #tempPolicyData where AccountNumber = @AccountNumberEND