当前位置: 代码迷 >> Sql Server >> ,请帮帮忙!@!多谢!
  详细解决方案

,请帮帮忙!@!多谢!

热度:86   发布时间:2016-04-27 20:30:51.0
各位高手,请帮帮忙!!!!!在线等@!谢谢!!!

以下这句话,我该如何写呢????
if   not   exists(select   *   from   @tabname   where   [email protected])

谢谢!!!

------解决方案--------------------
放在同一个变量里,这样试一下

declare @sql varchar(8000)
set @sql= 'if not exists(select * from '[email protected]+ ' where material_id= '+rtrim(@materialid)
print(@sql+ '
insert into '[email protected]+ '(material_id,levelonecode,levelonename,leveltwocode,leveltwoname,levelthreename)
values( ' ' '[email protected]+ ' ' ', ' ' '[email protected]+ ' ' ', ' ' '[email protected]+ ' ' ', ' ' '[email protected]+ ' ' ', ' ' '[email protected]+ ' ' ', ' ' '[email protected]+ ' ' ')
')

------解决方案--------------------
declare @sql varchar(8000)
set @sql= 'if not exists(select 1* from '[email protected]+ ' where material_id= '+rtrim(@materialid)
exec(@sql)
  相关解决方案