Sql Linked Server Query With Parameters
I need to select value from SQL Linked Server & get it to loacal variable This is what I've written so far: DECLARE @SQLQUERY AS VARCHAR(1000) DECLARE @FINALQUERY AS VARCHAR(10
Solution 1:
Instead of exec, use sp_execute_sql with an output parameter:
exec sp_executesql @FinalQuery, N'@OutVal output', @OutVal=@OutValoutSince sp_executesql expects nvarchar parameters, be sure to change the definition of @FinalQuery to nvarchar(max).
Post a Comment for "Sql Linked Server Query With Parameters"