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

如何通過鏈接服務器輕松使用 TVP?

How can I easily use TVPs with a linked server?(如何通過鏈接服務器輕松使用 TVP?)
本文介紹了如何通過鏈接服務器輕松使用 TVP?的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

問題描述

問題:

我正在使用鏈接服務器從遠程服務器調用存儲過程.雖然這在大多數情況下都能正常工作,但我有許多使用表值參數 (TVP) 的存儲過程.MSSQL 無法調用用作參數 TVP 的遠程 SP.

I am using a linked server to call stored procedures from a remote server. While this works fine most of the times, I have a number of stored procedures that use table-valued parameters (TVPs). MSSQL cannot call remote SPs that use as parameters TVPs.

解決方法是在遠程 sql 上執行 sql 并在那里構建 tvps.這再次工作正常.

The workaround is to execute sql on the remote sql and build there the tvps. Again this works fine.

問題是我必須編寫字符串才能調用 SP.如果我的 TVP 很少,這或多或少是容易的,但我的 SP 有很多 TVP.

The problem is that I have to compose the string to call the SP. In the case when I have few TVPs, this is more or less easy, but I have SPs with a lot of TVPs.

現在,在分析存儲過程調用時,在 TVP 參數存儲過程的情況下,從 .NET 到 sql 的調用如下所示:

Now, when profiling a Stored Procedure call, the call from .NET to sql in case of a TVP parameter stored procedure looks like:

declare @p1 <type>
insert into @p1 values(...)
insert into @p1 values(...)

...

exec myProc @p1

我想做的是在我的服務器上做一個包裝器(與 sp 遠程相同)并在使用 exec sql 調用遠程服務器內.

What I want to do is a wrapper on my server (identical with the sp remote) and within call the remote server with exec sql.

現在有人如何(如果可以)從存儲過程訪問此查詢?訪問它自己的分析器,如查詢,以便我可以遠程發送?

Does anyone now how can I (if I can) access this query from a stored procedure? Access it's own profiler like query so that I can just send it remote ?

推薦答案

好的,所以基本上解決方案是這樣的(那種自動化了一半的問題):

Ok, so basically the solution is this (that kind of automates half of the problem) :

declare @tvpVal_string nvarchar(max) = 'declare @tvpVal myTVPType;'
set tvpVal_string += isnull(stuff((select ';insert into @tvpVal values('+...your values...+')' as [text()] from @tvpVal from xml path('')),1,1,'')+';','');

declare @sql nvarchar(max) = tvpVal_string + 
'exec myProc @tvpVal=@tvpVal,
             @OtherVal=@OtherVal'

exec [REMOTESRV].DB..sp_executesql @sql,'@OtherVal type',@OtherVal

這篇關于如何通過鏈接服務器輕松使用 TVP?的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!

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

相關文檔推薦

Modify Existing decimal places info(修改現有小數位信息)
The correlation name #39;CONVERT#39; is specified multiple times(多次指定相關名稱“CONVERT)
T-SQL left join not returning null columns(T-SQL 左連接不返回空列)
remove duplicates from comma or pipeline operator string(從逗號或管道運算符字符串中刪除重復項)
Change an iterative query to a relational set-based query(將迭代查詢更改為基于關系集的查詢)
concatenate a zero onto sql server select value shows 4 digits still and not 5(將零連接到 sql server 選擇值仍然顯示 4 位而不是 5)
主站蜘蛛池模板: 天天拍天天射 | 日韩av成人在线 | 国产一级片免费在线观看 | 久久精品一级 | 欧美一级久久久猛烈a大片 日韩av免费在线观看 | 欧美激情a∨在线视频播放 成人免费共享视频 | 久久久久久久亚洲精品 | 欧美在线一区二区三区 | 国产aⅴ精品 | 射欧美 | 中文字幕一区二区三区乱码在线 | 91久久北条麻妃一区二区三区 | 成人性视频在线播放 | 国产欧美视频一区二区三区 | 欧美一级二级在线观看 | 亚洲日韩中文字幕一区 | 久久久av| 国产毛片久久久久久久久春天 | 国产精品18hdxxxⅹ在线 | 久久com | 久久精品色欧美aⅴ一区二区 | 亚洲国产成人精品久久久国产成人一区 | 午夜影院网站 | 久久久久国产精品 | 久久久久国 | 日韩精品在线一区 | 在线视频 亚洲 | 日本久久网 | 91麻豆精品一区二区三区 | 亚洲欧美一区二区三区情侣bbw | 亚洲视频一区 | www.日本精品 | 伊人网站在线观看 | 国产激情一区二区三区 | 99久久久久久 | 国产一区二区三区四区三区四 | 欧美中文字幕一区二区三区亚洲 | 欧美 日韩 视频 | 成人精品国产免费网站 | 久久久久久电影 | 国产精品视频综合 |