-- 创建表
CREATE TABLE Employees (
EmployeeID INT PRIMARY KEY,
EmployeeName NVARCHAR(100),
EmployeeEmail NVARCHAR(100)
);
-- 为表添加描述
EXEC sp_addextendedproperty
@name = N'MS_Description',
@value = N'员工信息表',
@level0type = N'Schema', @level0name = dbo,
@level1type = N'Table', @level1name = Employees;
-- 为列添加描述
EXEC sp_addextendedproperty
@name = N'MS_Description',
@value = N'员工ID',
@level0type = N'Schema', @level0name = dbo,
@level1type = N'Table', @level1name = Employees,
@level2type = N'Column', @level2name = EmployeeID;
EXEC sp_addextendedproperty
@name = N'MS_Description',
@value = N'员工姓名',
@level0type = N'Schema', @level0name = dbo,
@level1type = N'Table', @level1name = Employees,
@level2type = N'Column', @level2name = EmployeeName;
EXEC sp_addextendedproperty
@name = N'MS_Description',
@value = N'员工电子邮件',
@level0type = N'Schema', @level0name = dbo,
@level1type = N'Table', @level1name = Employees,
@level2type = N'Column', @level2name = EmployeeEmail;
IF EXISTS (SELECT * FROM sys.all_objects WHERE object_id = OBJECT_ID(N'[dbo].[Employees]') AND type IN ('U'))
DROP TABLE [dbo].[Employees]
CREATE TABLE [dbo].[Employees] (
EmployeeID int not null,
EmployeeName nvarchar(100),
EmployeeEmail nvarchar(100)
)
ALTER TABLE [dbo].[Employees] SET (LOCK_ESCALATION = TABLE)
EXEC sp_addextendedproperty 'MS_Description', N'员工信息表', 'SCHEMA', N'dbo', 'TABLE', N'Employees'
EXEC sp_addextendedproperty 'MS_Description', N'员工ID', 'SCHEMA', N'dbo', 'TABLE', N'Employees', 'COLUMN', N'EmployeeID'
EXEC sp_addextendedproperty 'MS_Description', N'员工姓名', 'SCHEMA', N'dbo', 'TABLE', N'Employees', 'COLUMN', N'EmployeeName'
EXEC sp_addextendedproperty 'MS_Description', N'员工电子邮件', 'SCHEMA', N'dbo', 'TABLE', N'Employees', 'COLUMN', N'EmployeeEmail'
ALTER TABLE [dbo].[Employees] ADD CONSTRAINT [PK_Employees] PRIMARY KEY (EmployeeID)