日期:2014-05-17 浏览次数:20509 次
select top 0 a.out_no, a.line,a.out_date into #temp99 FROM out_stock a
set @sqla='insert into #temp99 select a.out_no, a.line,a.out_date FROM out_stock a'
exec @sqla
set @sqlb= 'select * FROM out_stock a,#temp99'
exec @sqlb
--就是这个意思呗,结果没错
if object_id('Tempdb..#a') is not null drop table #a
if object_id('Tempdb..#b') is not null drop table #b
create table #a(
[Id] int null,
[Title] nvarchar(100) null
)
create table #b(
[Id] int null,
[Memo] nvarchar(100) null
)
Insert Into #a
select 1,'a' union all
select 2,'b' union all
select 3,'c' union all
select 4,'d' union all
select 5,'e'
select * from #a
declare @sqla nvarchar(100)
declare @sqlb nvarchar(100)
set @sqla='Insert Into #b(Id) select Id from #a '
exec(@sqla)
set @sqlb='select * from #a,#b'
exec(@sqlb)
-----------------------
(5 行受影响)
Id Title
----------- ----------------------------------------------------------------
1 a
2 b
3 c
4 d