如何解决为什么@@ identity,Scope_identity和Ident_current都返回NULL?
我尝试了以下代码来比较@@identity
,Scope_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';
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。