Ask the Expert

Where are default constraint values stored?

In SQL Server, where are the values for the default constraint for a particular column stored? What is the column name that holds the value?

    Requires Free Membership to View

Implementing a default value for a column, if a value is not passed, is a great best practice when developing systems, because all of the logic is inline to the table. As such it is not necessary to write complex logic if a value is not passed and if a NULL value is not inserted.

To find the values it is necessary to query the syscolumns table for the particular column. The syscolumns table resides in the user database and stores one record for each column in a specific table. The syscolumns table also has a column named 'cdefault' that serves as an ID for the column and references syscomments. The syscomments table stores the definition of the default in the 'text' column.

For more information about defaults visit:
Creating and Modifying DEFAULT Definitions

For More Information

This was first published in April 2004

Join the conversationComment

Share
Comments

    Results

    Contribute to the conversation

    All fields are required. Comments will appear at the bottom of the article.