你的问题出在对变量的赋值上了,应该用:SELECT @a=@@IDENTITY,
以下是我按你的要求做的例子,SQLServer 2008中测试正确:
Create Table login
(sId int IDENTITY PRIMARY KEY,
Name varchar(40) ,
Password varchar(40),
alevel varchar(40))
go
Create Table uninfo
(uid int)
go
declare @a INT
Insert Into login (Name,Password,alevel)
values (7,7,4)
Select * From login
SELECT @a=@@IDENTITY
insert into uninfo (uid) values (@a)
Select * From uninfo
go
drop table login
go
drop table uninfo
go
insert into [table2](uninfo) values(insert into [table1] values(7,7,4)select @@Identity)
你试试行不行,我对@@IDENTITY参数也不是很了解。。希望能帮到你。。