Click here to monitor SSC
SQLServerCentral is supported by Redgate
Log in  ::  Register  ::  Not logged in
Home       Members    Calendar    Who's On

Add to briefcase ««12

Default Constraint Not Reflected on Table Expand / Collapse
Posted Monday, October 1, 2012 4:37 AM



Group: General Forum Members
Last Login: Thursday, September 29, 2016 5:30 AM
Points: 424, Visits: 1,271
dwain.c (10/1/2012)
dwain.c (10/1/2012)
sqlusers (10/1/2012)
Hi Guys,

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!
Post #1366474
« Prev Topic | Next Topic »

Add to briefcase ««12

Permissions Expand / Collapse