SQLTeam.com | Weblogs | Forums

Alter table to add PK

Hi All,

I have a table already consist 14773583 rows data. I tried to alter a column to be PK to existing table. However failed due to timeout.

ALTER TABLE [dbo].[tblIP] ADD CONSTRAINT [PK_tblIP] PRIMARY KEY CLUSTERED (
[RecNo] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, SORT_IN_TEMPDB = OFF, IGNORE_DUP_KEY = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
GO

I tried, right click the column, modify. Set PK. Also, given me error timeout.

Anyone can advise me how to alter a column to be PK?

Thanks.

Regards,
Micheale

Try to increase the timeout value and run the script.
keep in mind this operation will lock the table until it is completed.

1 Like

Hi,

Many Thanks.

Regards,
Micheale