0

I would like to add a column to an existing table, where the new column would only have running numbers starting from 1. If I've understood correctly, the "create index" command is not the right way to do this, as that's attached to just certain columns to speed up querying.

The reason why I want this is that after exporting the data from the database I would still need to know the order of the rows.

2
Contributors
3
Replies
4
Views
8 Years
Discussion Span
Last Post by sknake
0
Create Table TestTable
(
  SomeInt int,
  SomeString varchar(10)
)

GO
--This adds an auto number column
Alter Table TestTable Add RowNumber int identity(1, 1)
0
Create Table TestTable
(
  SomeInt int,
  SomeString varchar(10)
)

GO
--This adds an auto number column
Alter Table TestTable Add RowNumber int identity(1, 1)

Thanks! That did the trick! :)

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.