I cant see where you're initializing @Counter variable. That may be the issue you're facing!Anyways I dont think you need loop either.you could simply do the belowDeclare @Issu2 varchar(max), @Reiss2 varchar(max);SELECT @Issu2 = STUFF((SELECT Char(13) + Char(10) + CAST(intIssuedId AS varchar(7)) FROM Drat_ReIssueHist where intReIssueId in (40888,40889,40890,40891) FOR XML PATH('')),1,2,''),@Reiss2 = STUFF((SELECT Char(13) + Char(10) + CAST(intReIssueId AS varchar(7)) FROM Drat_ReIssueHist where intReIssueId in (40888,40889,40890,40891) FOR XML PATH('')),1,2,'')select @Issu2, @Reiss2
------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/https://www.facebook.com/VmBlogs