I think dynamic SQL is going to be a problem with all the parameters and escaping them etc.By "Best" I was after whatever you guys have used and found to work best
What I had tried (which seems to work OK) is:DECLARE @strSQL Nvarchar(4000)SELECT @strSQL = N'EXEC [' + @MyLinkedServer + N'].MyRemoteDatabase.dbo.MySproc @Param1 = @Param1, @Param2 = @Param2 OUTPUT, @strErrMsg = @strErrMsg OUTPUT, @intRetVal = @intRetVal OUTPUT'EXEC @intErrNo = sp_ExecuteSQL @strSQL,N'@Param1 int,@Param2 int OUTPUT,@strErrMsg varchar(8000) OUTPUT,@intRetVal int OUTPUT', @Param1 = @Param1, @Param2 = @Param2 OUTPUT, @strErrMsg = @strTempErrMsg OUTPUT, @intRetVal = @intTempRetVal OUTPUT
my only (so far ...) gripe with this is the need to maintain the definition list if the Sproc's parameter's definitions change