hongclub
asked on
dynamic SQL while loop append variable
in my dynamic sql, i have a while loop, after i loop through a table, and then append the variable as result, here is my code
DECLARE @sqlmiddle NVARCHAR(MAX)
DECLARE @loop2 INT = 1
WHILE (@loop2 < = (Select count(*) from #SomeTable))
BEGIN
set @sqlmiddle = @sqlmiddle + somethingINTable
SELECT @loop2 = @loop2 + 1
END
how come it seems the @sqlmiddle not adding up, is my sytnax wrong?
DECLARE @sqlmiddle NVARCHAR(MAX)
DECLARE @loop2 INT = 1
WHILE (@loop2 < = (Select count(*) from #SomeTable))
BEGIN
set @sqlmiddle = @sqlmiddle + somethingINTable
SELECT @loop2 = @loop2 + 1
END
how come it seems the @sqlmiddle not adding up, is my sytnax wrong?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
This question has been classified as abandoned and is closed as part of the Cleanup Program. See the recommendation for more details.