Create Table

Below is the basic syntax for the create table script:

[cc lang=”sql”]
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
)
[/cc]

Featured Articles

 Site Author

  • Thanks for visiting!
css.php