久久久久久久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)
主站蜘蛛池模板: 欧美v免费 | 久久国产精品一区二区三区 | 日韩爱爱网 | 久久久久久免费看 | 一区二区国产精品 | 成人av观看 | 黄色毛片黄色毛片 | 久久久久久91香蕉国产 | 99热首页 | 精品日韩一区 | www.日日操 | 日本精品久久久久 | 国产1区2区| 日韩在线视频一区 | 亚洲人成人一区二区在线观看 | 在线免费av电影 | 欧美日韩在线一区二区 | 日韩一二三区视频 | 免费观看成人鲁鲁鲁鲁鲁视频 | 亚洲精品久久久一区二区三区 | 久久久精品一区 | 国产精品揄拍一区二区 | 久久精品免费 | 久久最新 | 国产成人福利视频在线观看 | 激情综合五月 | 亚洲福利网站 | 日韩免费一二三区 | 黄色片亚洲 | 影视先锋av资源噜噜 | 国产在线观看 | 精品欧美一区二区在线观看视频 | 亚洲精品久久久久久久不卡四虎 | 日本一区二区三区在线观看 | 天天操天天插 | 久久久久久久久久久久久久久久久久久久 | 国产精品国产自产拍高清 | 国产农村妇女精品一二区 | 久久精品亚洲 | 欧美一级片在线看 | 欧美日韩电影一区 |