判断指定库、表中是否有此字段

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不存在'
 
原文地址:https://www.cnblogs.com/yonguibe/p/4692702.html