I have a T-SQL select statement and I want to auto-increment a column in it (that doesn’t exist in the database)
select dbo.a, dbo.b, dbo.c, select @d:=1; @increment:=@increment+1 AS d
Is this possible?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Assuming you’re using SQL 2005 or later:
to order the rows as they are returned form the DB. If you want to specify an order you can do so:
For SQL 2000 and earlier you need a unique value to order by:
or if you don’t need a single SELECT: