Domanda

The following runs successfully:

EXEC sys.xp_readerrorlog 0

This however does not:

SELECT * 
FROM OPENROWSET(
    'SQLNCLI', 
    'Server=.;Trusted_Connection=Yes;',
    'EXEC sys.xp_readerrorlog 0')

I am logged in using my Windows account and I have sysadmin permissions on all databases on my local server, including the system databases.

Here is the error message:

Msg 7357, Level 16, State 2, Line 11
Cannot process the object "EXEC sys.xp_readerrorlog 0". The OLE DB provider "SQLNCLI10" for linked server "(null)" indicates that either the object has no columns or the current user does not have permissions on that object.

I've checked the folder permissions on C:\Windows\ServiceProfiles\LocalService\AppData just in case that it was an issue with OPENROWSET creating a temp file but local administrators (I'm in the group) have full control.

Why am I getting this error and how can I get around it?

È stato utile?

Soluzione

Try this:

SELECT * 
FROM OPENROWSET(
    'SQLNCLI', 
    'Server=.;Trusted_Connection=Yes;',
    'SET FMTONLY OFF;EXEC sys.xp_readerrorlog 0')

Basically, it's trying to infer the shape of the result before running the procedure.

Using that set option means the only way this will be possible is by executing the procedure.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top