Wednesday, March 12, 2014

Default Constraints

As part of very basic TSQL interview Question in interview
A default constraint is associated with a particular attribute. It is an expression that is used as
the default value when an explicit value is not specified for the attribute when you insert a row.
For example, the following code defines a default constraint for the orderts attribute in table
name order.

(representing the order’s time stamp):


The default expression invokes the SYSDATETIME function, which returns the current date and
time value. After this default expression is defined, whenever you insert a row in the Orders
table and do not explicitly specify a value in the orderts attribute, SQL Server will set the
attribute value to SYSDATETIME.
Run clean up code DROP TABLE dbo.Orders, dbo.Employees;

No comments:

Post a Comment