怎么样判断一个临时表已经存在??? if Exists(select * from tempdb..sysobjects where name = '#tempTbl1')print '存在'elseprint '不存在' 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 if object_id(tempTbl ) is not null insert into #tempTbl select * from 表1 where 字段1='a'else select * into #tempTbl from 表1 where 字段1='b' if object_id('tempdb..#tempTbl') is not null insert #tempTbl select * from 表1 where 字段1='a'else select * into #tempTbl from 表1 where 字段1='b' pengdali(大力 V3.0) 厉害! if object_id('tempdb..temptablename') is not nullprint 'exists' if object_id('tempdb..#tempTbl') is not null insert #tempTbl select * from 表1 where 字段1='a'else select * into #tempTbl from 表1 where 字段1='b' if object_id('tempdb..#tempTbl') is not nullprint '存在'elseprint '不存在' 上面的做法是正确的,可是当表中存在一个标识列时,insert #tempTbl select * from 表1 where 字段1='a'提示: 仅当使用了列的列表,并且 IDENTITY_INSERT 为 ON 时,才能在表 '#temptbl' 中为标识列 指定显式值。 [Sqlcommand使用两次的简单问题] sql server 2005 复制 快照 bak文件做DB还原问题 求一个SQL SRV冗余解决方案。 Count(*)可以跟在where后面作为select的条件么?给个例子 帮我看一下这个sql语句该如何写,在线等...... SQL中对一列取唯一值并计数怎样实现? sql sql sql 快疯了 sqlserver中怎样能得到一个表的字段的描述的内容? Sql怎样写? 请教:如何用sql语句或其它脚本修改表名? 怎样动态创建临时表?
insert into #tempTbl select * from 表1 where 字段1='a'
else
select * into #tempTbl from 表1 where 字段1='b'
insert #tempTbl select * from 表1 where 字段1='a'
else
select * into #tempTbl from 表1 where 字段1='b'
print 'exists'
insert #tempTbl select * from 表1 where 字段1='a'
else
select * into #tempTbl from 表1 where 字段1='b'
print '存在'
else
print '不存在'
仅当使用了列的列表,并且 IDENTITY_INSERT 为 ON 时,才能在表 '#temptbl' 中为标识列 指定显式值。