Carla Wilson-484785 (11/11/2011)
Thank you for an interesting question.
I liked the parameters with the dynamic t-sql string, so I thought I'd try it out. I don't work with linked servers, but I was interested to see if I could use this parameter syntax. No, I got a syntax error. Looking at the BOL syntax, it looked to me as if the [ AT linked_server_name ] was optional, but apparently not?
The "AT linked server" is optional, however, for a local query one would not likely use dynamic SQL with parameters to populate a variable, as it can be done directly ,e.g.
SELECT @Var1 = ColumnA FROM Table WHERE ColumnX = @Var2
The use of placehoders was designed explicitly for remote execution, to eliminate the need to build strings, converting variables to varchar etc.
It does appear to make the code more readable as well...
Space, the final frontier? not any more...
All limits henceforth are self-imposed.“libera tute vulgaris ex”