if exists(select 1 from syscolumns where id=object_id('表a') and name ='item') print '有'
if exists(select 1 from syscolumns where name = 'item' and id = object_id('a')) print '存在'
if exists (select 0 from syscolumns where id=object_id('a') and name='item') print '有'
--这样? if exists(select 1 from sysobjects o, syscolumns B where o.id = B.id and O.type = 'U' and o.name = '表A' and B.name = 'item') begin print '存在' end else print '不存在'
if exists(select 1 from syscolumns where id=object_id('表a') and name ='item') print '有' 支持这个
select * from sys.columns where [name] = 'xxxx'
---------------------------------------------------------------------------------------------- if exists(select * from sys.objects o, sys.columns B where o.object_id = B.object_id and O.type = 'U' and o.name = 'a' and B.name = 'item') begin print 'you' end else print 'wu' 结果是:wu ---------------------------------------------------------------------------------------------- if exists(select * from sys.objects o, sys.columns B where o.object_id = B.object_id and o.name = 'a' and B.name = 'item') begin print 'you' end else print 'wu' 结果是:you ---------------------------------------------------------------------------------------------- IF EXISTS (SELECT * FROM sys.objects O,sys.columns C WHERE O.object_id = OBJECT_ID('a') AND C.object_id=O.object_id and C.name = 'item') print 'you' else print 'wu' 结果是:wu ---------------------------------------------------------------------------------------------- IF EXISTS (SELECT * FROM sys.objects O,sys.columns C WHERE O.object_id = OBJECT_ID('a') AND C.object_id=O.object_id and C.name = 'item') begin print 'you' end else print 'wu' 结果是:wu ---------------------------------------------------------------------------------------------- IF EXISTS (SELECT * FROM sys.objects O,sys.columns C WHERE O.object_id = OBJECT_ID('a') and C.name = 'item') begin print 'you' end else print 'wu' 结果是:you --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
print '有'
from syscolumns
where name = 'item' and id = object_id('a'))
print '存在'
print '有'
--这样?
if exists(select 1 from sysobjects o, syscolumns B
where o.id = B.id and O.type = 'U' and o.name = '表A' and B.name = 'item')
begin
print '存在'
end
else
print '不存在'
print '有'
支持这个
where [name] = 'xxxx'
----------------------------------------------------------------------------------------------
if exists(select * from sys.objects o, sys.columns B
where o.object_id = B.object_id and O.type = 'U' and o.name = 'a' and B.name = 'item')
begin
print 'you'
end
else
print 'wu'
结果是:wu
----------------------------------------------------------------------------------------------
if exists(select * from sys.objects o, sys.columns B
where o.object_id = B.object_id and o.name = 'a' and B.name = 'item')
begin
print 'you'
end
else
print 'wu'
结果是:you
----------------------------------------------------------------------------------------------
IF EXISTS (SELECT * FROM sys.objects O,sys.columns C
WHERE O.object_id = OBJECT_ID('a') AND C.object_id=O.object_id and C.name = 'item')
print 'you'
else
print 'wu'
结果是:wu
----------------------------------------------------------------------------------------------
IF EXISTS (SELECT * FROM sys.objects O,sys.columns C
WHERE O.object_id = OBJECT_ID('a') AND C.object_id=O.object_id and C.name = 'item')
begin
print 'you'
end
else
print 'wu'
结果是:wu
----------------------------------------------------------------------------------------------
IF EXISTS (SELECT * FROM sys.objects O,sys.columns C
WHERE O.object_id = OBJECT_ID('a') and C.name = 'item')
begin
print 'you'
end
else
print 'wu'
结果是:you
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------