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?

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

Dig deeper on SQL Server Stored Procedures



Enjoy the benefits of Pro+ membership, learn more and join.

Have a question for an expert?

Please add a title for your question

Get answers from a TechTarget expert on whatever's puzzling you.

You will be able to add details on the next page.



Forgot Password?

No problem! Submit your e-mail address below. We'll send you an email containing your password.

Your password has been sent to: