存储过程写临时表
1.创建临时表
create table #cursor ( Id int, Name varchar
);
2.把查询到的数据添加进去,注意属性要一样。
insert into #cursor select * FROM [dbo].[biaoming]
insert into #cursor select Id,Name FROM [dbo].[biaoming2]
总体:
CREATE PROCEDURE [dbo].[Pdb_Excunchuguocheng] @RiJieRiQi datetime AS create table #cursor ( Id int, Name varchar ); insert into #cursor select * FROM [dbo].[biaoming] insert into #cursor select Id,Name FROM [dbo].[biaoming2] select * from #cursor GO
查询:
exec [dbo].[Pdb_Excunchuguocheng]
如果想添加与表无关联的数据,可以创建一个临时表在对主表修改
select * into #a from [dbo].[waijiashujubiao]
update #cursor set Name= #a.Name from #a