create index using openquery

一世执手 提交于 2021-02-10 18:44:24

问题


How do I create an index on a table that exist in a remote SQL Server database using the openquery syntax?


回答1:


You can't on your side. The index must be added to a local object only. You can't use an indexed view either.

You can ask the other party to add an index for you to their table...

Edit: Expanding John's answer... You could try:

SELECT * FROM OPENQUERY(LinkedServer, 'CREATE INDEX etc;SELECT 0 AS foobar')



回答2:


I'm not certain however I suspect that this cannot be done.

OPENQUERY is intended to return a Result Set and so is unlikely to accept DDL statements.

See the Microsoft Books Online reference for examples of acceptable usage scenarios.

http://technet.microsoft.com/en-us/library/ms188427.aspx



来源:https://stackoverflow.com/questions/1109476/create-index-using-openquery

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