为什么@@ identity,Scope_identity和Ident_current都返回NULL?

问题描述

我尝试了以下代码来比较@@identityScope_identity()Ident_current()的区别。令人惊讶的是,它们全都是NULL。我做错了什么?

create or alter procedure insert_bc (@brand varchar(25),@category varchar(25))
as 
begin
begin try
    Begin tran
        insert into [production].[brand] (brand_name)
        values (@brand)
        insert into [production].[category] ([category_name])
        values (@category)
    commit tran
select @@IDENTITY as ID_1
select SCOPE_IDENTITY() as ID_2
select IDENT_CURRENT('brand') as ID_3
select IDENT_CURRENT('category') as ID_4
end try
begin catch
    throw
end catch
end;

exec insert_bc 'DDD','CCCC';

enter image description here

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)