Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
Author |
Topic |
Hommer
Aged Yak Warrior
808 Posts |
Posted - 2014-07-14 : 11:01:38
|
Hey, Somehow I just couldn't get this to work. I could only get it to loop through once. What did I miss?declare @Row_No int =0;declare @I int = 0;while @Row_No < 3begin Set @Row_No +=1 while @I < 2 Begin Set @I +=1 print @Row_No print 'row then i' print @I END ENDThanks! |
|
James K
Master Smack Fu Yak Hacker
3873 Posts |
Posted - 2014-07-14 : 11:34:13
|
Don't you need to reset the internal variable before each loop?declare @Row_No int =0;declare @I int = 0;while @Row_No < 3begin Set @Row_No +=1SET @I = 0;while @I < 2BeginSet @I +=1print @Row_No print 'row then i'print @IEND END |
 |
|
Hommer
Aged Yak Warrior
808 Posts |
Posted - 2014-07-14 : 11:40:57
|
Ah, thanks!Without the reset, @I is maxed out at the end of first loop so it did not get me the second round. |
 |
|
|
|
|