August 25, 2008 at 10:29 pm
I dont know why my WHILE Loop os not working.
I tried running it in bits n pieces and still im not able to figure out what is wrong with it.
I hope you can help me.
Here is the script
--WHILE LOOP starts here
DECLARE @Count INT
DECLARE @Count_two INT
SET @Count = 0
SELECT @Count_two= Count(revi_id) from my_tbl
where bldng_id = @new_bld_id
print @count_two
print 'while loop to start'
WHILE @COUNT <> @COUNT_two
BEGIN
-- some insert statements
print @count
SET @count=@Count+1
END
Here my_tbl has 2 records with the selected where clause.
What I want is it should first go to first row then do the insert and then it should go to next row and then do insert.
I have tried using cursor also .. but all it takes is the last row two times and insert in executed two times for the same row.
Please help.
Thanks
K
August 26, 2008 at 1:18 am
Please post some insert statements too.
Viewing 2 posts - 1 through 1 (of 1 total)
You must be logged in to reply to this topic. Login to reply