Executing remote procedure with user-defined table type variable parameter

自古美人都是妖i 提交于 2019-11-30 23:05:27

Upon further research I discovered that table variables are invalid for remote procedure calls.

Instead, what I did was called EXEC [REMOTESERVER].[REMOTEDB]..sp_executesql and declared and populated my table variable and called the stored procedure all inside of that.

Example:

DECLARE @SQL nvarchar(4000)
SET @SQL = N'
DECLARE @tblVar dbo.user_defined_table_type
-- Code to populate table here
EXEC dbo.procedure_name (@param1 = @tblVar)
'
EXEC [REMOTESERVER].[REMOTEDB]..sp_executesql @stmt = @SQL

And that solved my problem. Hopefully this will help someone else out in the future.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!