Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2005 Forums
 SQL Server Administration (2005)
 timeout when setting PK

Author  Topic 

magmo
Aged Yak Warrior

558 Posts

Posted - 2008-09-17 : 04:23:02
Hi

I have a huge table that contains over a million records, I need to set a primary key on a bigint column, but when i do that in the designer I get a timout error, how should I proceed in order to get this to work?

sodeep
Master Smack Fu Yak Hacker

7174 Posts

Posted - 2008-09-17 : 09:06:06
Yes, it will lock the table because it has to sort million rows. Make sure that column has unique value and do it in Offline hours.
Go to Top of Page

magmo
Aged Yak Warrior

558 Posts

Posted - 2008-09-17 : 10:33:35
It is already a identity field so it is unique values. But I don't think it will work if I do it during offline hours, I have tryed this on a database that isn't used but it still fail. and I have timeout set to 0 so there shouldn't be any timeout at all.....
Go to Top of Page

YellowBug
Aged Yak Warrior

616 Posts

Posted - 2008-09-17 : 10:41:23
Run the CREATE INDEX sql statement, instead of using the GUI.

You can use the GUI to get the SQL statement.
Go to Top of Page

magmo
Aged Yak Warrior

558 Posts

Posted - 2008-09-21 : 13:31:17
Hi

That worked out just fine, Thanks a lot!
Go to Top of Page
   

- Advertisement -