Alter statement

  • I am trying to set a default value to an existing column in a database.

    Hence i try the syntax

    alter table tablename

    alter column columnname set default 'sand'

    but it throws error.

    Any help please.

    Thanks

  • ALTER TABLE

    ADD CONSTRAINT [constraint_name] DEFAULT [default value] FOR [column]

    Roland Alexander 
    The Monday Morning DBA 
    There are two means of refuge from the miseries of life: music and cats. ~ Albert Schweitzer

  • what you posted is the syntax for Oracle, I believe.

    SQl server is like this:

    alter table TableName

    add constraint df_ConstraintNAme

    default 'SANDNES' for [ColumnName]

    Lowell


    --help us help you! If you post a question, make sure you include a CREATE TABLE... statement and INSERT INTO... statement into that table to give the volunteers here representative data. with your description of the problem, we can provide a tested, verifiable solution to your question! asking the question the right way gets you a tested answer the fastest way possible!

  • Thanks guys,

    Worked perfectly.

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

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