insert of an int column with identity specification set to yes, fails

Hello experts:

I'm trying to insert an int column
with identity specification = yes
identity increment and identity seed = 1.
There are about 600,000 records on the database.
Before I try to execute this, I went to tools, options, query execution,
sql server, general and checked to make sure
execution time out was set to 0.
When I execute it, I get a message that warnings were encountered during the
pre-validation process and might reuslt in a failure during save. Then it also
says something about this query will take a long time.
When I click yes it starts execution and after a few minutes
get a message:
Unable to modify table. Timeout expired.

Any help will be greatly appreciated.
 
lancerxeAsked:
Who is Participating?

[Webinar] Streamline your web hosting managementRegister Today

x
 
Aneesh RetnakaranConnect With a Mentor Database AdministratorCommented:
why dont you run like this
 
ALTER TABLE yourTableName ADD newColumnName int identity
0
 
Shannon_LowderCommented:
Your timeout issue may be caused by locking.  Can you confirm no one is running any queries against that table at the time you're trying to add the identity column?
0
 
lancerxeAuthor Commented:
That worked except it added it to the end of the table.
It has to be the 1st column.
How could I do that.
thanks
0
 
Aneesh RetnakaranDatabase AdministratorCommented:
it doesn't matter whether it is the first or last column, you can of cource mention the order in which the values should be returned on you select query
SELECT col10, col1, col3 from table
if you still wanna put it as the first column, you need to create a new table with the new structure, insert the values from the existing table and then drop the old table and rename the new table
0
All Courses

From novice to tech pro — start learning today.