Add a default to a column

  • Show in SSMS and T-SQL, how to add a default to a column at design time (CREATE) and later (ALTER).

    Be nice to add these defaults

    space for char field

    0 for numeric

    current date for date field

  • Hi Steve

    I'll take this.

    Regards

  • Excellent, this should be an easy one.

  • Hi Steve

    I'm going to have to pass on this. Workload means I don't currently have time to write an article that adds any value compared to what is already out there. Sorry. I've submitted a QOTD instead as penance.

    Anybody else able to do this?

  • No worries, we'll find someone else.

  • Since this is very well documented in Books Online, I have to ask, do you still want an article on this and, if so, should it be more of a "Spackle" article?

    --Jeff Moden


    RBAR is pronounced "ree-bar" and is a "Modenism" for Row-By-Agonizing-Row.
    First step towards the paradigm shift of writing Set Based code:
    ________Stop thinking about what you want to do to a ROW... think, instead, of what you want to do to a COLUMN.

    Change is inevitable... Change for the better is not.


    Helpful Links:
    How to post code problems
    How to Post Performance Problems
    Create a Tally Function (fnTally)

  • Yes, and Yes. We want to expand and cover things that are in BOL in a different way. A practical use for this in a short article that someone has implemented in production would be nice.

  • Steve Jones - SSC Editor (11/29/2011)


    Yes, and Yes. We want to expand and cover things that are in BOL in a different way. A practical use for this in a short article that someone has implemented in production would be nice.

    Understood and can do. I'll take this one on. Thank you for the guidance.

    I believe I still owe you one on getting BCP (and other methods) to produce column headers, as well. I'll see what I can do about that, as well.

    --Jeff Moden


    RBAR is pronounced "ree-bar" and is a "Modenism" for Row-By-Agonizing-Row.
    First step towards the paradigm shift of writing Set Based code:
    ________Stop thinking about what you want to do to a ROW... think, instead, of what you want to do to a COLUMN.

    Change is inevitable... Change for the better is not.


    Helpful Links:
    How to post code problems
    How to Post Performance Problems
    Create a Tally Function (fnTally)

Viewing 8 posts - 1 through 7 (of 7 total)

You must be logged in to reply to this topic. Login to reply