创建临时表时IDENTITY没有用
我今天用一个存储过程创建了一个临时表用来插入东西,代码如下
Alter PROCEDURE Book_GetMyComments
(
@UserID int
)
AS
create table #Total
(
id int IDENTITY(1,1),
Total int
)
insert into #Total(Total) select count(CommentID) from Book_Comments where UserID=@USerID
select a.Adddate,b.Title,a.BookID,c.Total,c.id from Book_CommentsThreads as a ,Book_Books as b,#Total as c
where a.BookID=B.bookid
order by a.Adddate Desc
DROp table #Total
GO
当我执行的时候
exec Book_GetMyComments @UserID=4
id的那一列确全部显示为数字“1”,我的临时表明显写了IDENTITY,可是为什么会出现这种情况呢?