dwain.c (10/1/2012) dwain.c (10/1/2012) sqlusers (10/1/2012)
I have created a Default Constraint for my table. But this is not reflected on my table.
EX: Column ImportDate has a Datetime Datatype with NOT NULL Constraint.
I have created a Default Constranit for this as
. But while checking the query this Constraint not getting reflected on my table.
Every time it shows NULL.
Can any one help on this?
Could it be that you are looking at records that were created before you added the DEFAULT constraint?
That is true. I was suggesting that maybe the DEFAULT constraint was added after some INSERTs were made, and that wouldn't of course affect data already saved. I didn't notice that the column the OP was referring to was NOT NULL.
I still reckon you're right though.
Note to OP: If you add a default constraint to an existing column that allows nulls
, SQL Server does not backfill the values to existing rows - you have to do that yourself!:-)