select COUNT (0) from 库名..syscolumns where id=object_id (‘库名 dbo.表名‘ ) and name =‘字段名 ‘
--判断数据中[TestTb]表中是否存在[Name]字段
if exists(
select
*
from
TestDB..syscolumns
where
id=object_id(
‘TestDB.dbo.TestTb‘
)
and
name
=
‘Name‘
)
print
‘字段Name存在‘
else
print
‘字段Name不存在‘
时间: 2024-11-05 16:00:52