当前位置: 代码迷 >> SQL >> 在存储过程中施行SQL字符串并存入全局临时表
  详细解决方案

在存储过程中施行SQL字符串并存入全局临时表

热度:93   发布时间:2016-05-05 14:52:01.0
在存储过程中执行SQL字符串并存入全局临时表

@Begin int,?
@Ending int
AS
declare @sSql varchar(500),@sStr varchar(500)
set @sSql= '(select * from titles where title_id is not null '
if @Begin ='1'
?set @[email protected]+'and pub_id=''0877'''
if @Ending <>''
?set @[email protected]+'and type=''mod_cook'''
set @[email protected] + ') temp'

set @sStr='select * into ##bb from'+ (@sSql)
exec(@sStr)
select * into #temp from ##bb?
drop table ##bb--一定要销毁全局临时表

——##标识全局临时表,#标识局部临时表

  相关解决方案