标签:nvarchar 判断 server int 临时表 object_id length where 临时
if(OBJECT_ID(‘tempdb.dbo.#tempTB‘) is not null)
begin
drop table #tempTB;
end
create table #tempTB(
ID int NULL,
Name nvarchar(50) NULL,
Pwd varchar(50) NULL
)
--查询所有列名
select name from tempdb.sys.columns where object_id = OBJECT_ID(‘tempdb.dbo.#tempTB‘)
--查询定义的列长度(以字节为单位)
select COL_LENGTH(‘tempdb.dbo.#tempTB‘,‘ID‘)
--判断表中是否包含列
if COL_LENGTH(‘tempdb.dbo.#tempTB‘,‘ID‘) is null
begin
print ‘不存在列‘
end
else
begin
print ‘存在‘
end
drop table #tempTB;
标签:nvarchar 判断 server int 临时表 object_id length where 临时
原文地址:https://www.cnblogs.com/huyueping/p/10342178.html