IF OBJECT_ID('tempdb..#employees') IS NOT NULL
BEGIN
DROP TABLE #employees
END
CREATE TABLE #employees
(
EmployeeID INT IDENTITY (1,1) CONSTRAINT PK_employee NOT NULL PRIMARY KEY CLUSTERED
,FirstName VARCHAR(50)
)
GO
INSERT INTO #employees (FirstName) VALUES ('John');
ALTER TABLE #employees
ADD
LastName VARCHAR(50) NULL
,SSN VARCHAR(9) NULL CONSTRAINT ssn_unique UNIQUE
,IsTerminated bit NOT NULL DEFAULT 0
,DateAdded datetime NOT NULL DEFAULT GETDATE()
,DateModified DATETIME NULL DEFAULT GETDATE()
,Comments VARCHAR(255) SPARSE NULL -- SQL Server 2008 sparse column
SELECT * FROM #employees
No comments:
Post a Comment