SQL server添加表并添加备注,使用sql创建

SQL server添加表并添加备注,使用sql创建_第1张图片
SQL server添加表并添加备注,使用sql创建_第2张图片
SQL server添加表并添加备注,使用sql创建_第3张图片
当我们在添加SQL server表的时候,我们总是可以看到有些设计或者快捷键ctrl+3或sp_Objitems table时能看到table的详细信息,列入备注之类那么如何使用代码表示呢?

create table StockCheck
(
ID int  identity(1,1) ,					-- 自增长
IDKey uniqueidentifier not null,					--行唯一Key 
CAS nvarchar(50) not null default(''),     					--CAS
--CatalogNo varchar(10) not null default(''),           		--存货编码
BottleCode  nvarchar(50) not null default(''),            		--瓶号
ZfdNo nvarchar(50) not null default(''),             		--自封袋瓶号
Tracking nvarchar(50) not null default(''),						--批次号
InventoryLocation varchar(255) not null,					--库存货位
RealLocation varchar(255) not null,					--实际货位
Inventory decimal(18, 8) not null default(''),				--库存量
CheckModel nvarchar(10) not null default(''),      			--盘点模式:0-自封袋模式  1-瓶身盘点
CheckRemarks nvarchar(500) not null default(''),				--盘点备注
CheckTime datetime not null default(getdate()),						--盘点时间
CheckUserCode nvarchar(10) not null default(''),				--盘点人编号
CheckUserName nvarchar(10) not null default(''),				--盘点人姓名
CheckStatus	nvarchar(10) not null default('0'),				--盘点状态(-1-删除;0-全部;1-正常;2-有实物异常;3-无实物异常)
AuditStatus nvarchar(10) not null default('1'),				--审核状态(-1-删除 0-全部  1-未审核 2-审核通过 3-自动审核)
AuditTime datetime not null default(getdate()),						--审核时间
AuditUserCode nvarchar(10) not null default(''),				--审核人编号
AuditUserName nvarchar(10) not null default(''),				--审核人姓名
Lycatalog_No varchar(50) not null default(''), 				--商品号
CompanyCode nvarchar(20) not null  default ('HHSW'), 				--所属公司编号
StockID varchar(50) not null default(''),                  --仓库编码
)
go


EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'数据行自增ID' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'StockCheck', @level2type=N'COLUMN',@level2name=N'ID'
GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'行唯一Key' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'StockCheck', @level2type=N'COLUMN',@level2name=N'IDKey'
GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'CAS' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'StockCheck', @level2type=N'COLUMN',@level2name=N'CAS'
GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'瓶号' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'StockCheck', @level2type=N'COLUMN',@level2name=N'BottleCode'
GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'自封袋瓶号' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'StockCheck', @level2type=N'COLUMN',@level2name=N'ZfdNo'
GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'批次号' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'StockCheck', @level2type=N'COLUMN',@level2name=N'Tracking'
GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'库存货位' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'StockCheck', @level2type=N'COLUMN',@level2name=N'InventoryLocation'
GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'实际货位' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'StockCheck', @level2type=N'COLUMN',@level2name=N'RealLocation'
GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'库存量' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'StockCheck', @level2type=N'COLUMN',@level2name=N'Inventory'
GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'盘点模式' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'StockCheck', @level2type=N'COLUMN',@level2name=N'CheckModel'
GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'盘点备注' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'StockCheck', @level2type=N'COLUMN',@level2name=N'CheckRemarks'
GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'盘点时间' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'StockCheck', @level2type=N'COLUMN',@level2name=N'CheckTime'
GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'盘点人编号' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'StockCheck', @level2type=N'COLUMN',@level2name=N'CheckUserCode'
GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'盘点人姓名' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'StockCheck', @level2type=N'COLUMN',@level2name=N'CheckUserName'
GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'盘点状态(-1-删除;0-全部;1-正常;2-有实物异常;3-无实物异常)' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'StockCheck', @level2type=N'COLUMN',@level2name=N'CheckStatus'
GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'审核状态(-1-删除  0-全部 1-未审核 2-审核通过 3-自动审核)' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'StockCheck', @level2type=N'COLUMN',@level2name=N'AuditStatus'
GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'审核时间' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'StockCheck', @level2type=N'COLUMN',@level2name=N'AuditTime'
GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'审核人编号' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'StockCheck', @level2type=N'COLUMN',@level2name=N'AuditUserCode'
GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'审核人姓名' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'StockCheck', @level2type=N'COLUMN',@level2name=N'AuditUserName'
GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'商品号' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'StockCheck', @level2type=N'COLUMN',@level2name=N'Lycatalog_No'
GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'所属公司编号' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'StockCheck', @level2type=N'COLUMN',@level2name=N'CompanyCode'
GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'仓库编码' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'StockCheck', @level2type=N'COLUMN',@level2name=N'StockID'
GO

添加新的字段时,添加字段和描述

-- 添加字段
alter table StockCheck add ApprovalComments nvarchar(500) default('');

-- 加注释
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'审批操作意见' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'StockCheck', @level2type=N'COLUMN',@level2name=N'ApprovalComments'
GO

在这里插入图片描述

未来什么都不确定,你为什么要这么努力?
正是因为未来什么都不确定,所以我一定要全力以赴。

你可能感兴趣的:(Sql,server,sql,数据库)