default in table

  • Hi,

    how to give default value to a existing column in table.

    example.

    create table rr(s varchar(1) null)

    now i like to add default value to s column. i tried following.

     

    alter table rr alter column s varchar(1) default 'N'

    but it is giving syntax is wrong.

    thanx

     

     

     

  • Lookup CREATE DEFAULT

    and sp_bindefault

  • Alter Table rr

    ADD CONSTRAINT DF_rr_s  DEFAULT 'N' FOR s


    * Noel

  • create table rr(s varchar(1) null)

    varchar(1) ???

    This is only an example, right? If not, you should change it to char.

     

    --
    Frank Kalis
    Microsoft SQL Server MVP
    Webmaster: http://www.insidesql.org/blogs
    My blog: http://www.insidesql.org/blogs/frankkalis/[/url]

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

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