---
title: "Default Constraint in SQL Server"  
description: "In this blog, I’m explaining the default constraint in sql server and how to create it.  Defaults are the objects that can be bound to one or more col"  
author: "Sumit Kesarwani"  
published: 2013-05-29  
updated: 2014-09-18  
canonical: https://www.mindstick.com/blog/517/default-constraint-in-sql-server  
category: "database"  
tags: ["database"]  
reading_time: 2 minutes  

---

# Default Constraint in SQL Server

In this blog, I’m explaining the [default](https://www.mindstick.com/interview/12771/what-is-the-importance-of-default-resources) [constraint in sql](https://answers.mindstick.com/qa/92518/what-is-check-constraint-in-sql-server) [server](https://www.mindstick.com/articles/43769/what-is-serverless-architecture-is-it-worth-switching-over) and how to create it.\

Defaults are the [objects](https://www.mindstick.com/forum/145447/what-are-objects) that can be bound to one or more columns or [user defined](https://www.mindstick.com/forum/34125/how-to-find-list-of-all-user-defined-tables-using-sql-server) data type, making it possible to define them once and use them repeatedly. Defaults specify a value to add to a column when you do not insert a value into that column. Defaults are recorded in the sysobjects [system table](https://www.mindstick.com/forum/12964/how-can-i-create-a-sql-server-system-table) in each [database](https://www.mindstick.com/articles/12226/use-of-database-in-sencha-extjs-and-insert-record-from-user-form-using-ajax).

Creating a Default

Defaults are created by using CREATE DEFAULT statement.

##### Syntax:

CREATE DEFAULT default_name AS constant_expression

##### Example

CREATE DEFAULT dept AS 'IT'

##### Binding a Default

A default is a standalone object in the database , hence to use defaults, they have to be bound to a column or a data type. To bind a default, we have to use sp_bindefault system [stored procedure](https://www.mindstick.com/articles/803/using-stored-procedure-in-asp-dot-net).

##### Syntax:

Sp_bindefault Default_Name, Alias_Name.Column_Name

where

· Default_Name : Name of the default.

· Alias_Name .Column_Name : refers to the table.column to which the defaults to be bound.

##### Example

```
sp_bindefault dept, 'EMP.DEPT'
```

To see the effect of default, add a new row to the table and then view the table.

\
![Default Constraint in SQL Server](https://www.mindstick.com/blogs/f77f5b0c-4bb6-4b4c-b47b-996c4c5732ca/images/56f4e486-c438-4046-97ab-19878d36e2b7.jpg)

In this example, I’ve added two rows in first row I have not inserted the dept but in second I have inserted the dept. In first insert the dept value is coming from default dept coz we have bound it and in second insert dept value is coming from user input, you can see clearly in the output.

##### Unbind the Default

To unbind the default, we can use the sp_unbindefault system stored procedure.

##### Syntax:

Sp_unbindefault Object_Name

##### Example

sp_unbindefault 'EMP.DEPT'

##### Dropping a Default

A default cannot be dropped until and unless it has been unbounded from all data types and columns. Once the default unbounded from all the columns and data types it can be dropped using the DROP DEFAULT statement.

##### Syntax:

DROP DEFAULT Default_Name

##### Example

Drop default dept

---

Original Source: https://www.mindstick.com/blog/517/default-constraint-in-sql-server

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
