Author |
Topic |
daviddeldave
Starting Member
28 Posts |
Posted - 2003-03-10 : 11:57:01
|
In sql what is the equivalent for the for next loop in vb?David Mercer |
|
Page47
Master Smack Fu Yak Hacker
2878 Posts |
Posted - 2003-03-10 : 12:09:43
|
SQL is not a procedural language and thus contains no control-of-flow constructs.Transact-SQL is a SQL Server specific extension of SQL. It does contain some control-of-flow language bits and pieces. You can read about that in Books Online by searching on "control-of-flow language".Jay White{0} |
|
|
robvolk
Most Valuable Yak
15732 Posts |
Posted - 2003-03-10 : 12:31:22
|
You can also use tables that can substitute values for the numbers in a loop. Search SQL Team for "tally" or "sequence" and you'll find a number of examples. |
|
|
rharmon
Starting Member
41 Posts |
Posted - 2003-03-10 : 14:00:38
|
Begging your pardons, rob and page, but is this kinda what you are looking for?declare @counter intset @counter = 0while @counter < 20 begin set @counter = @counter + 1 print @counterend |
|
|
X002548
Not Just a Number
15586 Posts |
Posted - 2003-03-10 : 14:01:45
|
Wouldn't the following by sysnonomus?FOR I=1 to 10...some CodeNEXT ISET I = 1WHILE I < 11 BEGIN...some Code SET I = I + 1 ENDWhat's the difference?Brett8-) |
|
|
Page47
Master Smack Fu Yak Hacker
2878 Posts |
Posted - 2003-03-10 : 14:21:16
|
quote: Begging your pardons, rob and page, but is this kinda what you are looking for?
Nope. I'm not looking for anything.quote: SET I = 1 WHILE I < 11 BEGIN ...some Code SET I = I + 1 END
I think T-SQL would prefer an @I ...Jay White{0} |
|
|
X002548
Not Just a Number
15586 Posts |
Posted - 2003-03-10 : 14:29:28
|
My Bad Jay, Declare @I Int, it is.But isn't that construct a control of flow, like a FOR/NEXT?Brett8-) |
|
|
robvolk
Most Valuable Yak
15732 Posts |
Posted - 2003-03-10 : 14:33:08
|
Yeah, it is, but as Jay said it's not really SQL, it's an extension that T-SQL provides. |
|
|
Page47
Master Smack Fu Yak Hacker
2878 Posts |
Posted - 2003-03-10 : 14:46:28
|
... and daviddeldave did not ask for a t-sql extension ...sql is to vb as apples is to oranges.Microsoft spray paints their apples orange, which leads to much confusion ...Jay White{0} |
|
|
daviddeldave
Starting Member
28 Posts |
Posted - 2003-03-12 : 14:39:30
|
Thanks the while loop is what I was looking for.RegardsDavid Mercer |
|
|
JustinBigelow
SQL Gigolo
1157 Posts |
Posted - 2003-03-12 : 14:52:19
|
quote: sql is to vb as apples is to oranges.
Is that one of those SAT analogy questions? JustinExpect 0x80040106 |
|
|
|