Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase ««12

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


Old Hand

Old HandOld HandOld HandOld HandOld HandOld HandOld HandOld Hand

Group: General Forum Members
Last Login: Friday, June 27, 2014 8:03 AM
Points: 317, Visits: 1,079
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
GETDATE()

. 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