Duh, my bad Matt. I had a brain cramp. A primary key cannot contain a nullable column. I was thinking unique constraints which would be a natural or conceptual primary key. So this code will only allow the first insert to complete.
CREATE TABLE null_primary_key_test
(
id INT IDENTITY(1,1),
null_column INT NULL CONSTRAINT uc_null_column UNIQUE
)
GO
INSERT INTO null_primary_key_test (
null_column
)
SELECT NULL
-- the 2 causes the batch to execute twice
GO 2
DROP TABLE null_primary_key_test
Jack Corbett
Consultant - Straight Path Solutions
Check out these links on how to get faster and more accurate answers:
Forum Etiquette: How to post data/code on a forum to get the best help
Need an Answer? Actually, No ... You Need a Question