DEFAULT constraint in sql server


DEFAULT – This constraint provides a default value when specified none for this column.

Example-
Following create a table PRODUCT, column DTCREATE has default value GETDATE() it will store the system’s date-time by default if the value is not specified for this column.

CREATE TABLE PRODUCT
(
ID INT NOT NULL,
SKU VARCHAR(20) NOT NULL,
TITLE VARCHAR(200) NOT NULL,
PRICE MONEY NOT NULL,
DESCRIPTION VARCHAR(2000)  NULL,
DTCREATE DATETIME DEFAULT GETDATE()
)

If the PRODUCT table has already been created and you want to apply default price in the PRICE column use the following query (for SQL server).


ALTER TABLE PRODUCT ADD CONSTRAINT DF_SomePrice DEFAULT 20.00 FORPRICE

NUnit : Introduction

There are several unit test tools in the market, but one of them is NUnit, the most popular tool for doing unit testing. So in this tutorial...