set default value

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • vinodkus@gmail.com

    set default value

    dear sir/madam
    what is the syntex for changing default value.
    table name is test
    uno numeric(9)
    name1 char(10)
    address char(10)

    default value of addres is set to 'delhi'

    i have to change it to 'patna'

    please give me query for it

    thanks in advance
  • Dan Guzman

    #2
    Re: set default value

    what is the syntex for changing default value.
    table name is test
    uno numeric(9)
    name1 char(10)
    address char(10)
    >
    default value of addres is set to 'delhi'
    >
    i have to change it to 'patna'
    You first need the constraint name. This can be found with:

    EXEC sp_helpconstrai nt 'dbo.'test'

    You can then drop and recreate the constraint by name with a script like the
    example below. Just substitute the actual constraint name.

    ALTER TABLE dbo.test
    DROP CONSTRAINT DF_test_address

    ALTER TABLE dbo.test
    ADD CONSTRAINT DF_test_address
    DEFAULT ('patna') FOR address

    --
    Hope this helps.

    Dan Guzman
    SQL Server MVP


    Comment

    Working...