Tuesday, December 11, 2012

Cannot process the object "EXEC [DB_Name].dbo.SP_Name". 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.

If you are trying to run a stored procedure using OPENROWSET, for example:


SELECT *
   FROM OPENROWSET('SQLNCLI','Server=(LOCAL);Trusted_Connection=Yes;Database=DB_Name','EXEC [DB_Name].dbo.SP_Name')


and you got the following error:


Cannot process the object "EXEC [DB_Name].dbo.SP_Name". 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.


to solve this, just add SET FMTONLY OFF as the following:


SELECT *
   FROM OPENROWSET('SQLNCLI','Server=(LOCAL);Trusted_Connection=Yes;Database=DB_Name','SET FMTONLY OFF
EXEC [DB_Name].dbo.SP_Name'
)




4 comments:

  1. After adding 'SET FMTONLY OFF' also I am getting same error

    ReplyDelete
  2. Same error with this in 2012.

    ReplyDelete
  3. You are a genius! I had to remove the 'Server=(LOCAL);' part but works for me...

    ReplyDelete
  4. I also still get the same error (on SQL 2008 R2 SP2)
    with or without 'SET FMTONLY OFF' and/or 'Server=(LOCAL);'

    ReplyDelete