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
)

One comment
Ade 27 Nov 2015 at 8:35 pm

說道:1.在Notes中設定描述:2. 產生DDL的對話框中,Comment選擇「Column」(若是Table跟Column都要產生Comment,選擇All):3.3. 按下Generate即可(產生的SQL檔):CREATE TABLE BlameEmployee MS_Description nvarchar 50 — 案件編號 ; EXEC sp_addextendedproperty ‘MS_Description’, ‘案件編號’, ‘Schema’, dbo, ‘table’, BlameEmployee, ‘column’, MS_Description;

Featured Articles

 Site Author

  • Thanks for visiting!