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 |
|
nic
Posting Yak Master
209 Posts |
Posted - 2004-10-01 : 16:45:09
|
| Hi,I need to return a result set that is autonumbered. ie. 1-xx where xx is some number greater than 1. For example, is xx = 6 it would be:Result123456Each number would be a seperate row. I'm not really querying any table, I just need the ordered result set. Something like this:select 'hello world' as resultResulthello worldThis is a totally random question but there might be an easy solution....Nic |
|
|
eyechart
Master Smack Fu Yak Hacker
3575 Posts |
Posted - 2004-10-01 : 17:54:50
|
| you could creat a temp table that includes a column with an identity seed, insert your data into the temp table and then select from it. Kind of roundabout way, but it is doable.-ec |
 |
|
|
eyechart
Master Smack Fu Yak Hacker
3575 Posts |
|
|
Shurgenz
Yak Posting Veteran
51 Posts |
Posted - 2004-10-04 : 00:40:58
|
| select t*5+t1 from (select 0 t union select 1 union select 2 union select 3 union select 4) a,(select 1 t1 union select 2 union select 3 union select 4 union select 5) b1-25 ... You can use the idea to create own ranges |
 |
|
|
slacker
Posting Yak Master
115 Posts |
Posted - 2004-10-04 : 02:54:13
|
| Too bad you couldnt use that to generate a rownumber against a table. |
 |
|
|
Shurgenz
Yak Posting Veteran
51 Posts |
Posted - 2004-10-04 : 07:07:35
|
| to generate autonumber for table you may use as followsselect t1.filed1, count(t2.field2) from t t1 join t t2 on t1.field2>=t2.field2 and t1.field1=t2.field1group by t1.field1if field2 - is a field of datetime or number type, and you wish to count all fields according growing dates or numbers, then this query will autonumber field1 (on wich tables joined in query)it is just a sample, but, question was in autonumber only... |
 |
|
|
|
|
|