In SQL Server:
When a Primary Key is dropped, SQL Server:
Removes the NOT NULL
constraint from the column if it was only enforced via the PK.
It does not automatically change any values to NULL
.
So how did the NULLs get there?
Those rows were probably already there, but the column had default values (e.g., autogenerated or inserted earlier).
Once you dropped the PK and altered the column to allow NULLs (or SQL Server did that for you), subsequent operations (like inserts) may have inserted NULL
into those rows — especially if:
There was no default value set.
Your application/data import inserted rows without setting a value for that column.
SELECT COUNT(*)
FROM YourTableName
WHERE YourColumnName IS NULL;
SELECT* FROM YourTableName
WHERE YourColumnName IS NULL;
Delete FROM YourTableName
WHERE YourColumnName IS NULL;