久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

使用 SQL Server 從跨服務(wù)器插入獲取最后一個(gè) ID

Getting Last Id from a Cross Server Insert using SQL Server(使用 SQL Server 從跨服務(wù)器插入獲取最后一個(gè) ID)
本文介紹了使用 SQL Server 從跨服務(wù)器插入獲取最后一個(gè) ID的處理方法,對(duì)大家解決問題具有一定的參考價(jià)值,需要的朋友們下面隨著小編來(lái)一起學(xué)習(xí)吧!

問題描述

我正在運(yùn)行跨服務(wù)器插入

I am running a cross server insert

INSERT INTO server.database.dbo.table (Field) VALUES('test')

之后,我需要獲取最后一次插入的 id.但是,當(dāng)我運(yùn)行 scope_identity 函數(shù)時(shí),我沒有從外部服務(wù)器獲取最新的 id.

Afterward, I need to get the id of the last insert. However, when I run the the scope_identity function, I don't get the latest id from the foreign server.

SELECT @ID=SCOPE_IDENTITY()

如何從跨服務(wù)器插入中檢索最后一個(gè) ID?

How would I retrieve the last id from a cross server insert?

推薦答案

來(lái)自 http://msdn.microsoft.com/en-us/library/ms187342.aspx

@@IDENTITY 函數(shù)的作用域是本地服務(wù)器上的當(dāng)前會(huì)話在其上執(zhí)行.這個(gè)功能不能應(yīng)用于遠(yuǎn)程或鏈接服務(wù)器.獲取身份值在不同的服務(wù)器上,執(zhí)行該遠(yuǎn)程存儲(chǔ)過程或鏈接服務(wù)器并存儲(chǔ)過程(在遠(yuǎn)程或鏈接的上下文服務(wù)器)收集身份值和將其返回到調(diào)用連接本地服務(wù)器.

The scope of the @@IDENTITY function is current session on the local server on which it is executed. This function cannot be applied to remote or linked servers. To obtain an identity value on a different server, execute a stored procedure on that remote or linked server and have that stored procedure (which is executing in the context of the remote or linked server) gather the identity value and return it to the calling connection on the local server.

這篇關(guān)于使用 SQL Server 從跨服務(wù)器插入獲取最后一個(gè) ID的文章就介紹到這了,希望我們推薦的答案對(duì)大家有所幫助,也希望大家多多支持html5模板網(wǎng)!

【網(wǎng)站聲明】本站部分內(nèi)容來(lái)源于互聯(lián)網(wǎng),旨在幫助大家更快的解決問題,如果有圖片或者內(nèi)容侵犯了您的權(quán)益,請(qǐng)聯(lián)系我們刪除處理,感謝您的支持!

相關(guān)文檔推薦

Converting Every Child Tags in to a Single Column with multiple Delimiters -SQL Server (3)(將每個(gè)子標(biāo)記轉(zhuǎn)換為具有多個(gè)分隔符的單列-SQL Server (3))
How can I create a view from more than one table?(如何從多個(gè)表創(chuàng)建視圖?)
Create calculated value based on calculated value inside previous row(根據(jù)前一行內(nèi)的計(jì)算值創(chuàng)建計(jì)算值)
How do I stack the first two columns of a table into a single column, but also pair third column with the first column only?(如何將表格的前兩列堆疊成一列,但也僅將第三列與第一列配對(duì)?) - IT屋-程序員軟件開發(fā)技
Recursive t-sql query(遞歸 t-sql 查詢)
Convert Month Name to Date / Month Number (Combinations of Questions amp; Answers)(將月份名稱轉(zhuǎn)換為日期/月份編號(hào)(問題和答案的組合))
主站蜘蛛池模板: 国产午夜一级 | 91人人爽 | 人人cao| 91精品国产一区二区三区 | 日韩在线观看网站 | 免费永久av | 97精品国产97久久久久久免费 | 天堂色网 | 久草热视频| 成人av电影网 | 成人毛片网站 | 成人黄色av | 精品欧美乱码久久久久久 | 亚洲一二三区av | 小川阿佐美pgd-606在线 | 国产精品久久久久一区二区三区 | 亚洲黄色av | 不卡的av一区 | 亚洲成人一级 | 国产欧美一区二区三区日本久久久 | 妖精视频一区二区三区 | 毛片免费观看视频 | 日韩一区二区成人 | 国产一区 | 亚洲精品小视频在线观看 | 91久操视频 | 日本不卡免费新一二三区 | 精品一区二区三区四区五区 | 涩色视频在线观看 | 成人三级影院 | 黄频免费 | www.国产一区 | 国产精品久久久久久久久久久久久 | 久草www | 国产精品日韩 | 国产激情免费视频 | 99精品欧美一区二区三区综合在线 | 欧美精品乱码久久久久久按摩 | 久久久精品一区二区三区四季av | 久久精品色欧美aⅴ一区二区 | 99视频免费播放 |