Call sqlcmd commands in stored procedure code

时光怂恿深爱的人放手 提交于 2020-01-06 03:21:46

问题


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:


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



来源:https://stackoverflow.com/questions/16777001/call-sqlcmd-commands-in-stored-procedure-code

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!