1

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 ':'.

1
  • SQL Server Management Studio has a sqlcmd compatible mode. The ancient Query Analyzer has a similar mode, but you have to talk to old folk to see how to enable it... Commented May 27, 2013 at 19:49

1 Answer 1

2

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...

Sign up to request clarification or add additional context in comments.

1 Comment

I am sorry for very long delay after your detailed response - I was looking for any other solution to implement openrowset/openquery over Linked Server. Actually you answered my question and I need to open another tread to find solution for that.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.