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 |
|
ten2the6
Starting Member
7 Posts |
Posted - 2004-10-07 : 11:13:34
|
| Hey everyone ...Here is what I have today ...declare @recCount intset @recCount = 1while(@a<@b)begin if( @recCount = 1 ) select @recCount else union select @recCount--correctionset @recCount = @recCount + 1 endRESULTS inIncorrect syntax near the keyword 'union'.What I expected was to see ids------1------2------I do not want to use temp tables.Please help! |
|
|
jsmith8858
Dr. Cross Join
7423 Posts |
Posted - 2004-10-07 : 11:30:18
|
quote: I do not want to use temp tables.
Why not? You could use a table variable. Or store a permanent table of Numbers in your database and just access it when you need to (that will be the most efficient way).- Jeff |
 |
|
|
surefooted
Posting Yak Master
188 Posts |
Posted - 2004-10-07 : 11:35:12
|
| From what you have posted, you set @recCount =1, but never change it during your loop so your if statement will always be true. Also, that is an incorrect use of 'union.' Can you post more of your code, or more of what your trying to do?-JonNow a "Yak Posting Veteran". |
 |
|
|
VIG
Yak Posting Veteran
86 Posts |
Posted - 2004-10-07 : 12:05:46
|
| select 10*a+b+1 numsfrom (select 0 a union all select 1 union all select 2 union all select 3 union all select 4 union all select 5 union all select 6 union all select 7 union all select 8 union all select 9) as a, (select 0 b union all select 1 union all select 2 union all select 3 union all select 4 union all select 5 union all select 6 union all select 7 union all select 8 union all select 9) as bwhere (10*a+b)<= @cntorder by 1 |
 |
|
|
|
|
|