各位高手,请帮帮忙!!!!!在线等@!谢谢!!!
以下这句话,我该如何写呢????
if not exists(select * from @tabname where material_id=@materialid)
谢谢!!!
------解决方案--------------------放在同一个变量里,这样试一下
declare @sql varchar(8000)
set @sql= 'if not exists(select * from '+@tabname+ ' where material_id= '+rtrim(@materialid)
print(@sql+ '
insert into '+@tabname+ '(material_id,levelonecode,levelonename,leveltwocode,leveltwoname,levelthreename)
values( ' ' '+@materialid+ ' ' ', ' ' '+@onematerialcode+ ' ' ', ' ' '+@onematerialname+ ' ' ', ' ' '+@twomaterialcode+ ' ' ', ' ' '+@twomaterialname+ ' ' ', ' ' '+@threematerialname+ ' ' ')
')
------解决方案--------------------declare @sql varchar(8000)
set @sql= 'if not exists(select 1* from '+@tabname+ ' where material_id= '+rtrim(@materialid)
exec(@sql)