I have a very large table (around 13 million rows) and I want to set the primary key for the tables. The problem is that given the large size of the database my computer crashes when I try to set the primary key for a table.
I suppose that SQL Server tries to set this key in every row it finds, so the memory consumption reaches the limit of my computer (6gb of memory). Is there any effective and alternative way to set the primary key without having these issues?
Here are a couple of options that might work:
Here's a change script to point you in the right direction:
ALTER TABLE tableName WITH NOCHECK
ADD CONSTRAINT PK_tableName PRIMARY KEY CLUSTERED (columnName)
WITH (FILLFACTOR = 75, ONLINE = ON, PAD_INDEX = ON)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With