从另一台服务器(链接服务器)获取@@身份 [英] get @@Identity from another server(linked server)
本文介绍了从另一台服务器(链接服务器)获取@@身份的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个链接服务器, 我想在链接服务器上的表中添加一条记录, 是否可以从具有链接服务器的另一台服务器获取@@ identity? (SQL Server 2005)
I have a linked server, I want to add a record to the table on the linked server, Is it possible take @@identity from another server with linked server? (SQL Server 2005)
推荐答案
您可以在链接服务器上创建一个存储过程,该存储过程将返回身份.
You can create a stored procedure on your linked server that will return the identity.
顺便说一句,您应该使用SCOPE_IDENTITY()
而不是@@IDENTITY
.
You should be using SCOPE_IDENTITY()
rather than @@IDENTITY
, by the way.
请参阅与该问题相关的与此相关的问题(获得该问题的最佳方法插入行的身份?).
See this related question (Best way to get identity of inserted row?).
这篇关于从另一台服务器(链接服务器)获取@@身份的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文