I am trying to select some data from Excel into my SQL query.
I have the following query:
SELECT*
FROM
openrowset('Microsoft.ACE.OLEDB.12.0',
'Excel 12.0;Database=S:\Nh\NHData.xlsx;',
'SELECT *
FROM [Pre Upgrade data$]') as t2
If I run this on my local SQL server instance, it works fine, however to get it to work, I had to follow the procedure outlined on the below link, setting the SQL server service to run as my user account.
http://www.aspsnippets.com/Articles/The-OLE-DB-provider-Microsoft.Ace.OLEDB.12.0-for-linked-server-null.aspx
Without changing the user, I would get the following error:
Cannot initialize the data source object of OLE DB provider "Microsoft.ACE.OLEDB.12.0" for linked server "(null)".
For obvious reasons I cannot change the SQL server user on my live SQL database server.
How can I get this to run?
Related
I connected my MS SQL Server database to Firebird using odbc. When I use a SELECT statement it works perfectly. The error occurs when I try to UPDATE. I get this error message:
The OLE DB provider "MSDASQL" for linked server "server_name" could not update table
The strange thing is, it can update some other tables in the same db, but not a select few.
I tried to export data from SQL Server 2014 to Excel.
I tried like this
insert into OPENROWSET('Microsoft.ACE.OLEDB.12.0', 'Excel 12.0
Xml;HDR=YES;Database=D:\testing.xlsx;',
'SELECT OI_NAME,OI_ADDRESSS FROM [Sheet1$]') select OI_NAME,
OI_ADDRESSS from OI_TEMP
But I get this error
OLE DB provider "Microsoft.ACE.OLEDB.12.0" for linked server "(null)" returned message "Unspecified error".
Msg 7303, Level 16, State 1, Line 1
Cannot initialize the data source object of OLE DB provider "Microsoft.ACE.OLEDB.12.0" for linked server "(null)".
I searched on the internet, and found this:
The SQL Server Error Message if a user have no rights for SQL Server TEMP directory OLE DB provider "Microsoft.Jet.OLEDB.4.0" for linked server "(null)" returned message "Unspecified error".
Msg 7303, Level 16, State 1, Line 1
Cannot initialize the data source object of OLE DB provider "Microsoft.Jet.OLEDB.4.0" for linked server "(null)".
But I assign permission is still does not work.
Why?
To export data from SQL to Excel, you need to follow 2 steps:
Step 1: Connect Excel to your SQL database (Microsoft SQL Server, MySQL, PostgreSQL...)
Step 2: Import your SQL data into Excel
The result will be the list of tables you want to query data from your SQL database into Excel:
Step1: Connect Excel to an external data source: your SQL database
Install An ODBC
Install A Driver
Avoid A Common Error
Create a DSN
Step 2: Import your SQL data into Excel
Click Where You Want Your Pivot Table
Click Insert
Click Pivot Table
Click Use an external data source, then Choose Connection
Click on the System DSN tab
Select the DSN created in ODBC Manager
Fill the requested username and password
Avoid a Common Error
Access The Microsoft Query Dialog Box
Click on the arrow to see the list of tables in your database
Select the table you want to query data from your SQL database into Excel
Click on Return Data when you’re done with your selection
To update the export automatically, there are 2 additional steps:
Create a Pivot Table with an external SQL data source
Automate Your SQL Data Update In Excel With The GETPIVOTDATA Function
I've created a step-by-step tutorial about this whole process, from connecting Excel to SQL, up to having the whole thing automatically updated. You might find the detailed explanations and screenshots useful.
I try on a few years ago, do it that way and it was not possible, I suggest you use this form to export data to Excel from SQL -server.
Font: Microsoft Developer Network
Create an excel file, then option Data -> From other source -> From SQL Server
Select input your server, user and password, then select database and choose your table.
See this video:
Video Tutorial - SQL server to Excel
Then, you can code a macro on VBA to update automatically excel file
sub Auto_Open ()
ActiveWorkbook.RefreshAll
end sub
I hope this help to you!
I have an Oracle linked server in my SQL Server database.
I log into SQL Server using local and then Windows authentication.
As the Administrator (which is the account that set up the linked server) I can query directly or embed in a stored proc and then execute the proc without a problem.
As my named user, which has full administrator rights and also has had all SQL Server Groups on the Windows security settings added, I can query my linked server just fine using either synonyms or the OpenQuery syntax. But if I try to execute one of the stored procedures, it will give me the error messages
Message 1:
The OLE DB provider "OraOLEDB.Oracle" for linked server "<server name>" reported an error. The provider did not give any information about the error.
Message 2:
Cannot execute the query "<query string>" against OLE DB provider "OraOLEDB.Oracle" for linked server "<server name>".
I have searched online and typically people see this emssage when trying to run an ad hoc query. My ad hoc query runs just fine. Still, I applied the solution selected, which was to check the "Allow inprocess" option on the OLEDB Provider. Doing that did not help.
any ideas?
Please enable "Allow in Process" option for the provider by opening up Linked Server > Providers and checking on "Allow in Process". For more detail information, please refer to the following link:
Demystifying SQL-Oracle Distributed Query Issues
http://blogs.msdn.com/b/bindeshv/archive/2008/05/21/demystifying-sql-oracle-distributed-query-issues.aspx
source:
http://social.msdn.microsoft.com/Forums/sqlserver/en-US/902f5edf-e357-4ee7-82e8-ea5760882985/cannot-fetch-a-row-from-ole-db-provider-oraoledboracle-for-linked-server-linkedservername?forum=sqldataaccess
I am developping some code that transfers data between SQL servers. In this phase, all my work is on the same server (local, where I am the owner), but I am already trying to implement the OPENROWSET functionnalities that will be used at production time (where data will be on different servers and where I will have to build queries for the transfers). The following 3 codes are supposed to do the very same thing, but the one making use of OPENROWSET is giving me an error ... Bref, I am stuck! if anyone could help...
3 parts naming: works
USE db1
SELECT * INTO dbo.myTable FROM db2.dbo.myTable
OPENDATASOURCE: works
USE db1
SELECT * INTO dbo.myTable FROM OPENDATASOURCE
('SQLOLEDB',
'Data Source=127.0.0.1\SQLEXPRESS;Integrated Security=SSPI'
).db2.dbo.myTable
OPENROWSET: does not work
USE db1
SELECT * INTO dbo.myTable FROM OPENROWSET
('SQLOLEDB',
'Trusted_Connection=yes;Server=(Local)',
'db2.dbo.myTable')
Where I am getting the following message:
OLE DB provider "SQLNCLI" for linked server "(null)" returned message "Login timeout expired".
OLE DB provider "SQLNCLI" for linked server "(null)" returned message "An error has occurred while establishing a connection to the server. When connecting to SQL Server 2005, this failure may be caused by the fact that under the default settings SQL Server does not allow remote connections.".
Of course I have tried to use the standard properties of my connection string (as with OPENDATASOURCE) but I was also getting the following error:
OLE DB provider "SQLNCLI" for linked server "(null)" returned message "Invalid authorization specification".
OLE DB provider "SQLNCLI" for linked server "(null)" returned message "Invalid connection string attribute".
For one thing: Your OPENROWSET statement isn't specifying the server instance.
Try
USE db1
SELECT * INTO dbo.myTable FROM OPENROWSET
('SQLOLEDB',
'Trusted_Connection=yes;Server=127.0.0.1\SQLEXPRESS',
'db2.dbo.myTable')
One aspect of our system requires our SQL Server instance to talk to a MySQL Server via a linked Server Connection.
MSSQL -> LinkedServer(MSDASQL ODBC Provider) -> MySQL ODBC Connector -> MySQL DB
The Table on the linked server is called in a SPROC along the lines of
CREATE PROCEDURE DoStuff
AS
SELECT a.ID, a.Name, b.OtherProperty
FROM MyDatabase..MyTable a
JOIN LINKSRVR...OtherTable b
ON a.ID = b.ID
GO
The problem is that the MySQL database lives on another network, only accessible by VPN & that the CREATE or ALTER statement breaks with the following error unless the VPN is active.
The OLE DB provider "MSDASQL" for linked server "LINKSRVR" reported an error.
The provider did not give any information about the error.
Cannot initialize the data source object of OLE DB provider
"MSDASQL" for linked server "LINKSRVR".
Is there anyway to force SQL Server to just go ahead and create the SPROC with the SQL I tell it and not to try and validate if the LinkedServer is up/down.
You'd have to "hide" the offending SQL from the compiler by placing it in a string and executing it as dynamic SQL.