SQLServer获取临时表列名
Posted 追你追到
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了SQLServer获取临时表列名相关的知识,希望对你有一定的参考价值。
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;
以上是关于SQLServer获取临时表列名的主要内容,如果未能解决你的问题,请参考以下文章