SQL Clone
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


Default Constraint Not Reflected on Table


Default Constraint Not Reflected on Table

Author
Message
laurie-789651
laurie-789651
SSChasing Mays
SSChasing Mays (616 reputation)SSChasing Mays (616 reputation)SSChasing Mays (616 reputation)SSChasing Mays (616 reputation)SSChasing Mays (616 reputation)SSChasing Mays (616 reputation)SSChasing Mays (616 reputation)SSChasing Mays (616 reputation)

Group: General Forum Members
Points: 616 Visits: 1272
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!:-)
Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum

































































































































































SQLServerCentral


Search