Results 1 to 4 of 4
  1. #1
    Join Date
    Dec 2002
    Location
    Montreal, Canada
    Posts
    44

    Unanswered: Scripting a Default Value for an INTEGER field

    Hello,

    I am trying to write an SQL command to set the default value of an integer column I have within a table.

    ALTER TABLE TableName alter column ColumnName int default 0

    Any suggetions?

  2. #2
    Join Date
    Jan 2003
    Location
    Massachusetts
    Posts
    5,800
    Provided Answers: 11
    So, what is the problem? Does the command give you an error?

  3. #3
    Join Date
    Jan 2008
    Location
    Billings, MT
    Posts
    14
    To add a default value to an existing column, you actually add a constraint using the format

    ALTER TABLE TableName
    ADD CONSTRAINT ConstraintName
    DEFAULT 0 FOR ColumnName
    Tom Rupsis
    Granite Peak Systems
    Phone: 406-672-8292
    Email: trupsis@granitepeaksys.com
    LinkedIn: www.linkedin.com/in/trupsis

  4. #4
    Join Date
    Dec 2002
    Location
    Montreal, Canada
    Posts
    44
    you da man Tom.

    killer profile as well... thanks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •