Try this:
ALTER TABLE Production.TransactionHistoryArchive
ADD CONSTRAINT PK_TransactionHistoryArchive_TransactionID PRIMARY KEY CLUSTERED (TransactionID);
From: http://msdn.microsoft.com/en-us/library/ms189039.aspx[^]
Note: Before using the
ALTER TABLE
command to add a
primary key, you'll need to make sure that the field is defined as
'NOT NULL'
-- in other words,
NULL
cannot be an accepted value for that field.
When a
PRIMARY KEY
constraint is added to an
existing column or columns in the table,
Microsoft SQL Server
checks the existing data in the columns to ensure that the existing data follows the rules for primary keys:
-No null values
-No duplicate values
If a
PRIMARY KEY
constraint is added to a column
that has duplicate or null values,
SQL Server
returns an error and does not add the constraint.
In addition have a look on:
ALTER TABLE (Transact-SQL)[
^]
To know how to change the length, precision, or scale of a column by specifying a new size for the column data type in the
ALTER COLUMN
clause