如何判断表中是否存在一字段
如题。我的Sql2005
我在网上查的应该是
if not exists(select * from syscolumns where id=object_id('JL_PonderationBill') and name='[UpdaterCode]')
Select 1
else
Select 0
但是为什么会返回1呢,表中明明有这个字段
谢谢朋友了。
[解决办法]
看错了。你的那个应该是对了。
你可以先运行
select * from syscolumns where id=object_id('JL_PonderationBill') and name='UpdaterCode'
或者
select * from sys.columns where object_id=object_id('JL_PonderationBill') and name='UpdaterCode'
应该是多了[]这个符号吧。