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
 Transact-SQL (2005)
 Setting up Primary Keys

Author  Topic 

JJ297
Aged Yak Warrior

940 Posts

Posted - 2009-04-10 : 14:18:50
I did a Select FName, LName, Recno into New Table from Old Table

There are 796819 rows

I'm having a hard time adding the primary keys because it's timing out. How can I add two primary keys to this table?

robvolk
Most Valuable Yak

15732 Posts

Posted - 2009-04-10 : 14:39:40
A table can only have one primary key. Do you mean you're creating a primary key with 2 columns?
Go to Top of Page

JJ297
Aged Yak Warrior

940 Posts

Posted - 2009-04-10 : 14:46:19
Yes that's what I need a primary key on two columns.

Go to Top of Page

robvolk
Most Valuable Yak

15732 Posts

Posted - 2009-04-10 : 15:31:41
ALTER TABLE NewTable ADD CONSTRAINT PK_NewTable PRIMARY KEY(Col1, Col2)

Books Online has more details under ALTER TABLE. Make sure all columns in the key are defined NOT NULL.
Go to Top of Page

JJ297
Aged Yak Warrior

940 Posts

Posted - 2009-04-10 : 15:51:04
Great thanks!
Go to Top of Page
   

- Advertisement -