adding default column with type BIT and default value as Y

  • Smash125

    Hall of Fame

    Points: 3527

    I want to add new column test to the table contact with type BIT with default value Y. PLease let me know how to do this

  • Thom A

    SSC Guru

    Points: 98011

    What have you tried so far? Have you had a look at the ALTER TABLE syntax? There are loads of examples in the documentation, why didn't your attempt work?

    Thom~

    Excuse my typos and sometimes awful grammar. My fingers work faster than my brain does.

  • ScottPletcher

    SSC Guru

    Points: 97936

    Bit data type is numeric in SQL: naturally 1 means Yes, 0 means No.

    So:

    CREATE TABLE dbo.table_name ( bit_column bit DEFAULT 1 );

    SQL DBA,SQL Server MVP(07, 08, 09) Prosecutor James Blackburn, in closing argument in the Fatal Vision murders trial: If in the future, you should cry a tear, cry one for them [the murder victims]. If in the future, you should say a prayer, say one for them. And if in the future, you should light a candle, light one for them.

Viewing 3 posts - 1 through 3 (of 3 total)

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