读书人

在存储过程中把查询结果保存下来,后面

发布时间: 2012-01-16 23:36:51 作者: rapoo

在存储过程中把查询结果保存下来,后面接着用?
在存储过程中,把查询结果保存下来,想用临时表,但是想在临时表中多加个字段作为主键,语句该如何写?
select aaa,bbb,ccc into #tempTableA(id int IDENTITY(1,1) not null primary key,aaa,bbb,ccc) from tableA where ....
这样行不?
怎么写才对呢?
谢谢!


[解决办法]
create table #tempTableA(id int IDENTITY(1,1) not null primary key,aaa int,bbb int)
insert into #tempTableA select aaa,bbb form table a where

读书人网 >SQL Server

热点推荐