首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 数据库 > SQL Server >

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

2012-07-08 
在存储过程中执行SQL字符串并存入全局临时表@Begin int,?@Ending intASdeclare @sSql varchar(500),@sStr

在存储过程中执行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 @sSql=@sSql+'and pub_id=''0877'''
if @Ending <>''
?set @sSql=@sSql+'and type=''mod_cook'''
set @sSql=@sSql + ') temp'

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

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

热点排行