简体   繁体   中英

Access denied when trying to run stored procedure on MS SQL Server

I am getting below error message when I am trying to run stored procedure.

Msg 7399, Level 16, State 1, Procedure accountupdater, Line 10 The OLE DB provider "Microsoft.ACE.OLEDB.12.0" for linked server "(null)" reported an error. Access denied. Msg 7350, Level 16, State 2, Procedure accountupdater, Line 10 Cannot get the column information from OLE DB provider "Microsoft.ACE.OLEDB.12.0" for linked server "(null)".

Additional information: previously it was working, but after installing MS Office it start to give an error message. We uninstalled MS Office and reinstalled “Microsoft Access Database Engine 2010”. Still getting error message.

Did some research and found that I need to install “Microsoft Access Database Engine 2010”. I did, but still getting the same error message.

ALTER PROCEDURE [dbo].[accountupdater]
AS
  DECLARE @accountNum numeric, @businessFEIN varchar(100), @stateID varchar(100), @dbaName varchar(100), @addressLine1 varchar(100), @addressLine2 varchar(100), @city varchar(100), @state varchar(100), @zip varchar(100), @businessName varchar(100)
  DECLARE accountCursor CURSOR FAST_FORWARD FOR
    SELECT * FROM OPENROWSET('Microsoft.ACE.OLEDB.12.0',
    'Text; HDR=YES; Database=D:\Innoprise\',
    'SELECT * FROM flagstaffAccountUpdate.csv') ors
  OPEN accountCursor

  --perform first fetch
  FETCH NEXT FROM accountCursor INTO @accountNum, @businessFEIN, @stateID, @dbaName, @addressLine1, @addressLine2, @city, @state, @zip, @businessName

  --check if there are more rows to fetch
  WHILE @@FETCH_STATUS = 0
  BEGIN  

  update BUSINESS SET FEIN=coalesce(@businessFEIN, FEIN), name=coalesce(@businessName, name) WHERE ID = (select business_id from VENDOR v where v.vendornumber=@accountNum);
  update DBA set name=coalesce(@dbaName, name) where id = (select primarydba_id from vendor v where v.vendorNumber=@accountNum);
  update VENDOR set stateId=coalesce(@stateID, stateID) where vendorNumber=@accountNum;
  update ADDRESS set addressLine1=coalesce(@addressLine1,addressLine1), ADDressline2=coalesce(@addressLine2,addressline2), 
  city=coalesce(@city,city), state=coalesce(@state,state), zipCode=coalesce(@zip,zipCode)
  where ID = (select v.address_ID from VENDOR v where v.vendorNumber = @accountNum);
  FETCH NEXT FROM accountCursor INTO @accountNum, @businessFEIN, @stateID, @dbaName, @addressLine1, @addressLine2, @city, @state, @zip, @businessName
END
  CLOSE accountCursor
  DEALLOCATE accountCursor

If you have installed Microsoft Access Database Engine 2010 already,then please execute following queries and restart SQL Server Management Studio or SQL Services. Refer here

USE [master] 
GO 
EXEC master.dbo.sp_MSset_oledb_prop N'Microsoft.ACE.OLEDB.12.0', N'AllowInProcess', 1 
GO 
EXEC master.dbo.sp_MSset_oledb_prop N'Microsoft.ACE.OLEDB.12.0', N'DynamicParameters', 1 
GO 

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM