Create Table
-
Posted on July 24, 2009 by Derek Dieter
-
1
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]
Post a comment
- Comments (RSS)
- Trackback
- Permalink