Create Table

Below is the basic syntax for the create table script:

CREATE TABLE dbo.Employees
(
  EmployeeID INT IDENTITY (1,1) NOT NULL CONSTRAINT PK_EmployeeID PRIMARY KEY NONCLUSTERED
  ,FirstName VARCHAR(50) NULL
  ,LastName VARCHAR(50) NULL
  ,SSN VARCHAR(9) NULL CONSTRAINT ssn_unique CHECK (SSN LIKE '[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9]') UNIQUE
  ,IsTerminated bit NOT NULL DEFAULT 0
  ,DateAdded datetime   DEFAULT GETDATE()
  ,Comments VARCHAR(255) SPARSE NULL -- SQL Server 2008 sparse column
)

Featured Articles

 Site Author