I want to read the default defined with a column constraint, so that I can implement code similar to the following inside a trigger:
INSERT MyTable (MyCol)
SELECT isnull(MyCol, dbo.GetDefault(MyCol))
This is to prevent the situation that when a NULL is explicity inserted into a column that doesn't allow NULLs but allows defaults, an error is generated.
I had hoped that something like this would work, but it doesn't:
INSERT MyTable (MyCol)
SELECT isnull(MyCol, DEFAULT)
Any ideas?