我在 SQL Server 2012 中创建了一个存储过程,我曾经scope_identity
获取过标识列的值,但在我的情况下,我不知道这是否正确请帮忙
CREATE PROCEDURE Add_Translation
@english nvarchar(70),
@kurdish nvarchar(70),
@english_category int,
@kurdish_category int,
@result int out
AS
BEGIN
SET NOCOUNT ON;
if @english is not null and @kurdish is not null and @english_category is not null and @kurdish_category is not null
begin
insert into english_table values(@english, @english_category);
declare @identityEnglish int;
set @identityEnglish = SCOPE_IDENTITY();
insert into kurdish_table values(@kurdish, @kurdish_category);
declare @identityKurdish int;
set @identityKurdish = SCOPE_IDENTITY();
insert into transactions values(@identityEnglish, @identityKurdish);
set @result = 1;
end
else
begin
set @result = 0;
end
END
我的问题是变量将@identityEnglish
获得最后一个身份值,english_table
而变量@identityKurdish
将获得最后一个身份值kurdish_table
谢谢你..