Link to home
Start Free TrialLog in
Avatar of hongclub
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?
ASKER CERTIFIED SOLUTION
Avatar of Member_2_861731
Member_2_861731
Flag of Canada image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
This question has been classified as abandoned and is closed as part of the Cleanup Program. See the recommendation for more details.