久久久久久久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的處理方法,對大家解決問題具有一定的參考價(jià)值,需要的朋友們下面隨著小編來一起學(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?

推薦答案

來自 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的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網(wǎng)!

【網(wǎng)站聲明】本站部分內(nèi)容來源于互聯(lián)網(wǎng),旨在幫助大家更快的解決問題,如果有圖片或者內(nèi)容侵犯了您的權(quán)益,請聯(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?(如何將表格的前兩列堆疊成一列,但也僅將第三列與第一列配對?) - IT屋-程序員軟件開發(fā)技
Recursive t-sql query(遞歸 t-sql 查詢)
Convert Month Name to Date / Month Number (Combinations of Questions amp; Answers)(將月份名稱轉(zhuǎn)換為日期/月份編號(hào)(問題和答案的組合))
主站蜘蛛池模板: 成人在线一区二区 | 亚洲成人在线网 | 一级黄色片美国 | 九九色综合 | 欧美日日日日bbbbb视频 | 精品视频免费 | 超碰520 | 99国产精品久久久久久久 | 欧美人妇做爰xxxⅹ性高电影 | 国产成人艳妇aa视频在线 | 国产色片 | 欧美激情久久久 | 精品久久久久久久久久久院品网 | 精品久久久久一区二区国产 | 亚洲一区二区三区免费在线 | 久久手机视频 | 亚洲色综合| 精品伊人| 久久av一区 | 久久久久久久一区二区 | 精品无码久久久久国产 | 亚洲综合资源 | 性一交一乱一透一a级 | 成年免费在线观看 | 96久久久久久 | 亚洲国产在 | 欧美性影院 | 毛片国产 | 亚洲高清在线免费观看 | 欧美视频在线观看 | 国产做a爱免费视频 | 成人在线免费观看视频 | 极品电影院 | 成人不卡视频 | 天堂精品| 免费精品视频 | 日本久久久久久 | 日韩中文在线 | 天天看天天干 | 欧美日韩亚 | 三极网站 |