Because of Linked Server is not easy to send openrowset query I connect to remote Sql Server directly via SQLCMD mode. But this is Ok using Query Analyzer. When I put code to stored procedure I cannot even save it:
:Connect x.x.x.x -U sa -P password
select *
from openrowset('VFPOLEDB','\\share\db\s_object.dbf';'';
'','SELECT * FROM s_object where i_class=21 order by 1')
Incorrect syntax near ':'.
sqlcmd mode
:connect
syntax is valid in SSMS and QA when sqlcmd mode is enabled, but it will always be a client side command, executed by SSMS or QA itself and never sent to the engine. As such by no way it can be embedded on a server side module, like a stored procedure. If you really mean stored procedure then no wonder the syntax error...