4

I am trying to run the below query to rebuild the index on a table on the Linked server, but it is not working. Can any one please let me know what I am doing wrong?

ALTER INDEX ALL ON [LinkedServerName].[dbname].[dbo].[tablename] REBUILD 
WITH (FILLFACTOR = 90)

This is giving me below error:

Cannot find the object "[LinkedServerName].[dbname].[dbo].[tablename]" because it does not exist or you do not have permissions.

6

Four-part-naming syntax is not supported for ALTER INDEX.

Try this:

EXEC ('ALTER INDEX ALL ON [dbname].[dbo].[tablename] REBUILD WITH (FILLFACTOR = 90);') 
AT LinkedServerName;
  • 3
    Or EXEC LinkedServerName.dbname.sys.sp_executesql 'ALTER INDEX ALL ON ...;'); – Aaron Bertrand Dec 28 '16 at 17:57

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy