日期:2014-05-18 浏览次数:20564 次
select (case when [f1]='' then '1' when [f1]='A' then '2' end) as f1 from #temp
if exists(select 1 from tempdb.dbo.syscolumns where ID=OBJECT_ID('Tempdb..#temp') and name='f1')
print '存在'
else
print '不存在'
------解决方案--------------------
create table #temp1 (f1 char(1))
create table #temp2 (f2 char(1))
use tempdb
if col_length('#temp1','f1') is not null
print 'exists'
else
print 'not exists'
--> exists
if col_length('#temp2','f1') is not null
print 'exists'
else
print 'not exists'
--> not exists
------解决方案--------------------