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.

 All Forums
 SQL Server 2000 Forums
 Transact-SQL (2000)
 Increment Row by 1 in a Select

Author  Topic 

load1982
Starting Member

3 Posts

Posted - 2008-07-20 : 17:44:11
Hope you can help me!!!!!!

I have a number stored in a Variable, i want to make a select statement. and incrementing each row by one, starting from the number i have stored in the Variable

examble:
Declare @ID int
Set @ID=11220

and with a select need to get something like this:

ID Description
11221 A
11222 B
11223 C
11224 D
11225 E

spirit1
Cybernetic Yak Master

11752 Posts

Posted - 2008-07-20 : 18:06:00
can't do it in a select in SQL Server 2000. you'll have to insert it into a temp table that has identity and then select from there.

but this really is a presentation issue and you should handle that there.

_______________________________________________
Causing trouble since 1980
Blog: http://weblogs.sqlteam.com/mladenp
Speed up SSMS development: www.ssmstoolspack.com <- version 1.0 out!
Go to Top of Page

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2008-07-20 : 18:31:04
[code]DECLARE @ID INT

SET @ID = 11220

SELECT Number + @ID AS ID,
CHAR(64 + Number) AS Description
FROM master..spt_values
WHERE Type = 'P'
AND Number BETWEEN 1 AND 5[/code]


E 12°55'05.25"
N 56°04'39.16"
Go to Top of Page
   

- Advertisement -