久久久久久久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)(問題和答案的組合))
主站蜘蛛池模板: 久久免费精品视频 | 日本视频中文字幕 | 午夜小视频免费观看 | 精品国产乱码久久久久久牛牛 | 欧美一级黄视频 | 亚洲一区二区在线免费观看 | 亚洲欧洲小视频 | 在线欧美视频 | 三级成人在线观看 | 国产视频一区在线 | 色综合久久天天综合网 | 干干干日日日 | 国产精品综合一区二区 | 欧美一级特黄aaa大片在线观看 | 欧美在线观看黄色 | 亚洲三区在线观看 | 91视视频在线观看入口直接观看 | 久久免费视频网 | 国产免费又色又爽又黄在线观看 | 精品欧美一区免费观看α√ | 国产成人一区二区三区电影 | 亚洲欧美日韩高清 | 日韩成人免费视频 | 九色在线视频 | 电影91久久久 | 成人精品一区亚洲午夜久久久 | 国产永久免费 | av先锋资源 | 国产精品永久免费视频 | 天天草天天 | 亚洲成人福利 | 欧美aa在线 | 亚洲综合激情 | 国产精品久久久久免费 | 精品一区二区三区四区五区 | 亚洲第一成人影院 | 日本在线你懂的 | 一区二区影视 | 久久一区视频 | 久久久久久久夜 | 天天夜夜人人 |