I have a table in SQL Server 2005 containing 10000054 records; these records are inserted through a bulk insert operation. The table does not contain a primary key and I want to have one. If I try to modify the table’s structure, adding a new column, PK, set as int with isidentity, the management console gives me a warning:
“Changes to tables with large amounts of data could take a considerable amount of time. While changes are being saved, table data will not be accessible.”
then outputs error:
”
Unable to modify table.
Timeout expired. The timeout period elapsed prior to completion of the operation or the server is not responding.
“
I want a PK into my table.
How can I add it?
make a new table with exact schema and make the desired column the primary key. Now using select to insert copy the records from one table to another.
When completed then delete the old table and rename this new table to the desired name.