March 24, 2004 at 9:18 am
Hi All,
Can anyone please suggest me how to do a auto increment in a select statement.
declare @x int
set @x = 1
select customerid,companyname, @x+1
from northwind..customers
This thing did not work for me, please suggest an alternative.
Thanks.
March 24, 2004 at 9:48 am
Are you looking for a "row number" type thing?
http://www.sqlservercentral.com/columnists/glarsen/sequentialnumbering.asp
March 24, 2004 at 9:27 pm
try @col1 = @col1 = col1+1
where type = @01
March 24, 2004 at 9:38 pm
try this
declare @col1 int
update dbo.tablename
set @col1 = col1 =isnull(Col1,0)+1
from dbo.incrementBYone
where anyfiled to identify the row = 1
select @col1
Viewing 4 posts - 1 through 3 (of 3 total)
You must be logged in to reply to this topic. Login to reply