从另一台服务器(链接服务器)获取@@Identity
我有一个链接服务器,我想在链接服务器上的表中添加一条记录,是否可以从具有链接服务器的另一台服务器获取@@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?).
相关文章