Link to home
Start Free TrialLog in
Avatar of lancerxe
lancerxe

asked on

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.
 
ASKER CERTIFIED SOLUTION
Avatar of Aneesh
Aneesh
Flag of Canada image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
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?
Avatar of lancerxe
lancerxe

ASKER

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
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