急救:怎样获取刚插入的记录的ID号并将其插入到另一个表中?
我在存储过程里写 
 DECLARE   @ID   INT   
 INSERT   INTO   Table   (Name)   VALUES   (@Name)   
 SELECT   @ID=@@Identity   
 INSERT   INTO   LOG   (LogID,Ip)   VALUES   (@ID,@Ip)   
 我的表Log里的LogID是不允许为空的,在asp.net页面里执行的时候会报错:LogID不允许插入空值 
 我要怎样写才可以将@@Identity的值插入到Log表中呢?
------解决方案--------------------我的测试没有问题啊 
 create table test 
 (Id int identity(1,1), 
  name varchar(10) 
 )   
 create table test1 
 ( 
 	logId int not null, 
 	Ip varchar(20)  	 
 )   
 create proc sptest 
 @name varchar(10),@Ip varchar(20) 
 as 
 declare @Id int 
 insert into test(name) values(@name) 
 set @Id=@@Identity   
 insert into test1(logId,Ip) values(@Id,@Ip)   
 sptest  'cao ', '120.0.0.0 '     
 (所影响的行数为 1 行)     
 (所影响的行数为 1 行)