SQL Server Agent cannot execute OPENROWSET query but I can - "Microsoft.ACE.OLEDB.12.0" for linked server "(null)" reported an error - sql

I'm trying to run an OPENROWSET query to an Excel sheet like so:
SELECT id, SourceName
FROM OPENROWSET('Microsoft.ACE.OLEDB.12.0',
'Excel 12.0; HDR=YES; IMEX=1; Database=D:\MyFolder\Configuration.xlsx', 'SELECT * FROM [Sheet1$]')
When I execute this from SSMS it works. As part of a job step, it doesn't work with the error stated.
Things I've tried:
sp_configure 'show advanced options', 1;
RECONFIGURE;
GO
sp_configure 'Ad Hoc Distributed Queries', 1;
RECONFIGURE;
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
Setting the permissions on the target spreadsheet & folders to 'Everyone' and 'Read/Write'
When I go to 'Server Objects' -> 'Linked Servers' -> 'Providers', Microsoft.ACE.OLEDB.12.0 is listed and it's in xp_enum_oledb_providers.
Access Database Engine x64 is installed.
This is SQL Server 2014.
Can anyone help? Why would the SQL Server Agent be unable to use the ACE provider when my user can?

Related

SQL SERVER - how can I rollback "use [MASTER]" query

I accidentally ran query Change authentication mode (T-SQL) in sql server:
USE [master]
GO
EXEC xp_instance_regwrite N'HKEY_LOCAL_MACHINE',
N'Software\Microsoft\MSSQLServer\MSSQLServer',
N'LoginMode', REG_DWORD, 1
GO
Now I can't work with SQL SERVER.
You can change it back using below code:
EXEC xp_instance_regwrite
N'HKEY_LOCAL_MACHINE',
N'Software\Microsoft\MSSQLServer\MSSQLServer',
N'LoginMode',
REG_DWORD,
2; -- only difference is right here
You have changed authentication mode to windows only. So now you have to log in using windows account then you can change the authentication mode to mixed mode again. Or you can edit your registry to do so. Please check below link:
https://www.top-password.com/knowledge/sql-server-authentication-mode.html

Can not run cmdshell #command in SQL Server Express

I can not run cmdshell #command commands in my SQL Server Express. Is it something to do with the SQL Server version? Should I have to have like SQL Server Standard edition to run this command?
Enable it, as described in the Microsoft article:
-- To allow advanced options to be changed.
EXEC sp_configure 'show advanced options', 1;
GO
-- To update the currently configured value for advanced options.
RECONFIGURE;
GO
-- To enable the feature.
EXEC sp_configure 'xp_cmdshell', 1;
GO
-- To update the currently configured value for this feature.
RECONFIGURE;
GO
It was a permission issue which is fixed now! Thank you all for the help!

How to Enable Create catalog Option in Integration Services Catalogs?

I want to create a SSIS catalog and the way to create a catalog is to right click on "Integration Services Catalogs" node and select "Create Catalog" option.
But "Create Catalog" option is disable , how to enable this option ?
To check if SSIS installed, open Sql Server Configuration Manager, in the SQL Server Services, is something like 'SQL Server Integration Services ' running?
I had this problem and I found the above solution in belew link:
Can't create a SSISDB catalog due to missing SSISDBBackup.bak file, even though SSIS is installed
Sp_configure 'show advanced options',1;
Go
Reconfigure;
Go
Sp_configure 'clr enabled',1;
Go
Reconfigure
Go
Run the above command from master database

System error 85 has occured in SQL Server 2005

I'm executing a batch file from SQL Server using this code:
exec sp_configure 'show advanced options', '1'
reconfigure
exec sp_configure 'xp_cmdshell','1'
reconfigure
exec xp_cmdshell '" D:\network.bat"'
and the neywork.bat contains the below commands
rem disconnect and re-set upn network drive connection
net use z: /d /yes
net use z:\\mlisfile07
Here the z: is mapped to some other path, but in the output it is showing as
network connection could not be found
system error 85 has occured
You are missing a space between the drive letter and the network path:
net use z: \\mlisfile07
~~~
The possible reason is that your logged in SQL-SERVER user doesn't have administrative permissions.
Please review : http://support.microsoft.com/kb/253821.

Cannot initialize the data source object of OLE DB provider "Microsoft.ACE.OLEDB.12.0" for linked server

I'm trying to establish a linked server from SQL Server 2008 R2 to an Access database. The Access database is not password protected. As I have seen in other posts (specifically this one), this is usually due to the current user not having access to the Temp folder inside the NetworkService folder. Since we are running this in Windows Server 2008, the directory structure is quite different than what most are eluding to. I have allowed access to every temp folder in the "root:\Documents and Settings\" directory, and to no avail.
This is the procedure I am using to add the linked server:
EXEC sp_addlinkedserver
#server = N'OS_Access',
#provider = N'Microsoft.ACE.OLEDB.12.0',
#srvproduct = N'',
#datasrc = N'C:\RTBData\Data\OS.mdb';
GO
It creates the linked server with no problem, but I am not able to view the tables/views of the database. Likewise, my ASP.NET application cannot access it either.
I have tried both ACE and JET(64-bit)(by installing the Data Connectivity Components for Office), and they both do not work. I have also tried configuring the ACE provider with "Dynamic Parameter" and "Allow InProcess" to true.
Additionally, I tried upping the memory usage by the MSSQLSERVER services by adding "-g512;" in front of "startup parameters" string in SQL configuration manager to rule out memory issues.
If anyone could shed some light on this that would be fantastic! Thanks!
UPDATE: I logged into SQL using the sa account, and I was able to view the linked server. My current user account has full permissions in SQL server, so I am unsure of what the difference is between the accounts. Maybe I gave permissions to the wrong Temp folder, in which the sa account (being built-in) has access to. If someone could point me in the right direction here, that would be great, and I think it would also help a lot of other people.
I fixed the problem by disabling UAC within the control panel. I am unsure what changes this made, but it might help others!
USE [master]
GO
EXEC sp_configure 'show advanced options', 1
RECONFIGURE
GO
EXEC sp_configure 'ad hoc distributed queries', 1
RECONFIGURE
GO
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
SELECT *
FROM OPENROWSET('Microsoft.ACE.OLEDB.12.0','Name & Location of DB';;, [TableName])