使用@ @ IDENTITY在SQL Server 2008:你如何填写与使用@ @ IDENTITY的
主表的主键连接表
我想从PhysicalTest表autoincremnt id和保存在我的连接称为PatientRecord
表 CREATE PROCEDURE procAddPhysicalTestCheck
@Height float,
@Weight float,
@BodyMass float,
@BloodPressure nvarchar(10),
@Temperature float,
@RespiratoryRate nvarchar(10),
@HeartRate float
AS
INSERT INTO PhysicalTest(Height,Weight,BodyMass,BloodPressure,Temprature,RespiratoryRate,HeartRate)
VALUES(@Height,@Weight,@BodyMass,@BloodPressure,@Temperature,@RespiratoryRate,@HeartRate)
SELECT @@IDENTITY AS 'Identity'
DECLARE @PhysicalID AS int
SET @PhysicalID = @@IDENTITY
INSERT INTO PatientRecord(PhysicalTestID)
VALUES(@PhysicalID)