日期:2014-05-18 浏览次数:20534 次
declare @0 varchar(8000) select @0='' select @0=@0+a from #tmp0 where gid=0 exec('select js_no,js_yxdate,js_xlm,js_ch,js_fbtime,js_bclx '+@0+' into # from djjj where js_hc=0 and js_xlm= case '''' when '''' then js_xlm else '''' end and js_yxdate between ''2011-11-20'' and ''2011-11-20''group by js_no,js_yxdate,js_xlm,js_ch,js_fbtime,js_bclx ')
select js_no,js_yxdate,js_xlm,js_ch,js_fbtime,js_bclx into # from djjj where js_hc=0 and js_xlm= case '' when '' then js_xlm else '' end and js_yxdate between '2011-11-20' and '2011-11-20' group by js_no,js_yxdate,js_xlm,js_ch,js_fbtime,js_bclx
--给你举个例子,你一看就明白当前会话的意思了 exec('create table #t(id int)') exec('select * from #t') /* invalid object name '#t'. */ exec('create table #t(id int) select * from #t') /* id ----------- (0 row(s) affected) */
------解决方案--------------------
declare @0 varchar(8000) select @0='' select @0=@0+a from #tmp0 where gid=0 exec('select js_no,js_yxdate,js_xlm,js_ch,js_fbtime,js_bclx '+@0+' into # from djjj where js_hc=0 and js_xlm= case '''' when '''' then js_xlm else '''' end and js_yxdate between ''2011-11-20'' and ''2011-11-20''group by js_no,js_yxdate,js_xlm,js_ch,js_fbtime,js_bclx select * from # ')
------解决方案--------------------