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 |
|
kathyc2003
Starting Member
15 Posts |
Posted - 2008-02-03 : 11:41:59
|
| Hello,I am trying to creating a while loop.I have created a variable called @MyCountwhich I initially set to 1.For each iteration of the loop, I wouldlike the value of @MyCount to increase by 1.What am I doing wrong?WHILE ( @MyCount <= @DaysInMonth )BEGIN /* put some code in here *./ @MyCount = @MyCount + 1ENDThanks |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2008-02-03 : 12:43:58
|
quote: Originally posted by kathyc2003 Hello,I am trying to creating a while loop.I have created a variable called @MyCountwhich I initially set to 1.For each iteration of the loop, I wouldlike the value of @MyCount to increase by 1.What am I doing wrong?WHILE ( @MyCount <= @DaysInMonth )BEGIN /* put some code in here *./ SET @MyCount = @MyCount + 1ENDThanks
Use SET to assign new value to count variable |
 |
|
|
subrata4allfriends
Starting Member
24 Posts |
Posted - 2008-02-03 : 13:08:55
|
| As per sql server syntax u have to declare a variable then set the value what value u want to assign to it.DECLARE MyCount INTSET @MyCount = @MyCount + 1Thanks & Regards,4allfriends."Life is not a bed of roses." |
 |
|
|
|
|
|