create proc test
as
select identity(int,1,1) FID,* into #A from 表a order by id
select identity(int,1,1) FID,* into #B from 表b order by id
insert temp
select 'A-'+cast(fid as varchar) ,m,n from #A where id=1
union all
select 'B-'+cast(fid as varchar) ,x,y from #B where id=1
select * from temp
drop table #a
drop table #b
as
select identity(int,1,1) FID,* into #A from 表a order by id
select identity(int,1,1) FID,* into #B from 表b order by id
insert temp
select 'A-'+cast(fid as varchar) ,m,n from #A where id=1
union all
select 'B-'+cast(fid as varchar) ,x,y from #B where id=1
select * from temp
drop table #a
drop table #b
解决方案 »
- 关于查看SQL2008日志的问题!
- 请教not in的问题
- 请问如何将多个 CONTAINS 谓词合并为一个 CONTAINS 谓词?
- 请问有关触发器
- 数据库服务器(MSSQL Server)无法启动了。太奇怪了(.ldf和.mdf备份出来每次恢复都数据不同),有高手能解决吗
- 跪求高手帮忙优化SQL语句
- 请教下高手如何同步同一个sql数据库服务器 三个数据库的用户表
- 在线求SQL语句:如何在已有数据的表中添加IDENTITY?
- 图形存储问题,请各位大虾赐教
- 特急!请教各位一个问题,如果您在vfp6.0中使用过DBF()这个函数.....
- 如何把int类型数据转化为datetime类型?
- 一个表中,怎样才能找到最新插入的数据???
as
select identity(int,1,1) FID,* into #A from 表a where id=1
select identity(int,1,1) FID,* into #B from 表b where id=1insert temp
select 'A-'+cast(fid as varchar) ,m,n from #A
union all
select 'B-'+cast(fid as varchar) ,x,y from #Bselect * from tempdrop table #adrop table #b
AS
SELECT IDENTITY(INT,1,1) IDD,* INTO #T_A FROM TableA
SELECT IDENTITY(INT,1,1) IDD,* INTO #T_B FROM TableB
INSERT INTO TEMP SELECT 'A-'+CAST(IDD AS CHAR(1)),M,N FROM #T_A WHERE ID<3
INSERT ITNO TEMP SELECT 'B-'+CAST(IDD AS CHAR(1)),M,N FROM #T_A WHERE ID<3
SELECT * FROM #T_A
DROP TABLE #T_A
DROP TABLE #T_BGO