Post

Cannot insert the value NULL into column ”, table ”; column does not allow nulls. INSERT fails.

I stumbled upon this error all of a sudden when I was working in a project. There was this SQL Server 2000 database that existed, that very few knew nothing about. This error message confused me a lot, because it didn’t show up when I was running some scripts from the Query Analyzer, but is showed up when I ran the exact same scripts from within a SSIS SQL task.

As it turned out, the database had some unknown owner. Here’s how to find out.

1
SELECT Name AS DBName, suser_sname(sid) AS Owner FROM master.dbo.sysdatabases WHERE suser_sname(sid) IS NULL

If you get any results, you can set an owner for those databases using:

1
2
USE <THE DATABASE NAME>
EXEC sp_changedbowner 'sa'

That should take care of the problem.

This post is licensed under CC BY 4.0 by the author.