Add Default Constraint to an Existing Column

This post is going to be short and sweet for two reasons:

1.  It is a short subject and

2.  I’m learning the Dvorak keyboard…

I recently needed to add a default constraint to an existing column.  It’s not something I have to do often so when I do do it I need to look it up.  The website Google sends me to has variations for several platforms but the Microsoft version isn’t working for me.

So here’s one I can reference any time I need to…

-- SQL 2005+
ALTER TABLE f_response
  ADD CONSTRAINT new_contact_flag_def
     DEFAULT 0
       FOR new_contact_flag;

This Dvorak is going to take some serious practice.

Stay curious… keep learning…

Dave

0 Comments

Leave a Reply

You must be logged in to post a comment.

Using Gravatars in the comments - get your own and be recognized!

XHTML: These are some of the tags you can use: <a href=""> <b> <blockquote> <code> <em> <i> <strike> <strong>