尝试 运行 MS SQL 服务器上的存储过程时访问被拒绝
Access denied when trying to run stored procedure on MS SQL Server
我在尝试 运行 存储过程时收到以下错误消息。
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)".
其他信息:以前它可以正常工作,但在安装 MS Office 后它开始显示错误消息。我们卸载了 MS Office 并重新安装了“Microsoft Access Database Engine 2010”。仍然收到错误消息。
做了一些研究,发现我需要安装“Microsoft Access Database Engine 2010”。我做了,但仍然收到相同的错误消息。
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
如果您已经安装了 Microsoft Access Database Engine 2010,请执行以下查询并重新启动 SQL Server Management Studio 或 SQL 服务。
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
我在尝试 运行 存储过程时收到以下错误消息。
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)".
其他信息:以前它可以正常工作,但在安装 MS Office 后它开始显示错误消息。我们卸载了 MS Office 并重新安装了“Microsoft Access Database Engine 2010”。仍然收到错误消息。
做了一些研究,发现我需要安装“Microsoft Access Database Engine 2010”。我做了,但仍然收到相同的错误消息。
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
如果您已经安装了 Microsoft Access Database Engine 2010,请执行以下查询并重新启动 SQL Server Management Studio 或 SQL 服务。 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