SQL查询表中是否存在某个字段
时间:2021-07-01 10:21:17
帮助过:210人阅读
*
from syscolumns
where name=
‘字段名‘ and id=object_id(
‘表名‘))
begin
select ‘已存在,不需添加!‘
end
ELSE
begin
ALTER TABLE dbo.MQ_PhysicalRoomAndExamineRoom add PhysicalRoomHISCode VARCHAR(36)
EXEC sys.sp_addextendedproperty @name=N
‘MS_Description‘, @value=N
‘注释‘ , @level0type=N
‘SCHEMA‘,@level0name=N
‘dbo‘, @level1type=N
‘TABLE‘,@level1name=N
‘表名‘, @level2type=N
‘COLUMN‘,@level2name=N
‘字段名‘
end
SQL查询表中是否存在某个字段
标签:min ble roo object_id his pre column select sch