I'm trying to update my SQL table with an excel file.
When I try to use OLEDB, I get the error:
Server: Msg 7308, Level 16, State 1, Line 1
OLE DB provider 'Microsoft.Jet.OLEDB.4.0' cannot be used for distributed queries because the provider is configured to run in single-threaded apartment mode.
I was trying the folowing query:
UPDATE x
SET x.ShopName = y.ShopName
FROM dbo.StandInStore x INNER JOIN
(
SELECT [Stand_ID], [ShopName]
FROM OPENROWSET('Microsoft.Jet.OLEDB.4.0', 'Excel 8.0;IMEX=1;Database=C:\Documents and Settings\vdbergv\Desktop\test.xls;', 'SELECT * FROM [Sheet1$]')) y
ON x.stand_ID = y.stand_ID
I have read/write wrights, but I think the server isn't supporting OLEDB, I'm not the administrator so I can't reconfigure the server, like many solutions on the internet.
Any idea how to solve this problem or an alternative for OLEDB?
Regards
Related
I am trying to connect to SQL Azure database from an on-premise SQL Server using openrowset, but it is failing with an error.
My query is
SELECT a.*
FROM OPENROWSET('SQLNCLI', 'Server=sqlazureserver.database.windows.net;Database=dbname;User ID=username;Password=password;Connection Timeout=30;', 'select * from [dbo].[tablename]') AS a;
and the error I get:
Msg 7399, Level 16, State 1, Line 11
The OLE DB provider "SQLNCLI11" for linked server "(null)" reported an error. Authentication failed.
Msg 7303, Level 16, State 1, Line 11
Cannot initialize the data source object of OLE DB provider "SQLNCLI11" for linked server "(null)".
I am able to successfully connect using linked server, but I do not want to go that route as my connection strings will be dynamic.
From documentation ,I could see open row set is not supported against SQL Azure database as of now.
Instead of openrowset,you can use distributed queries to accomplish the same
exec ('select * from table') at linkedserver
I've got 2 servers in a workgroup called "workgroup".
Server A is W2012R2 with SQL Server 2012.
Server B is W2012R2 with other application. SQLCMD Utility has been installed on server B.
I'm using local account, SQL service is start by local account. I can connect to the SQL server from B to A. I can launch query without difficulty. When I launch my SQL script, I get the following error:
E:\Batch\Script>sqlcmd -S YMSQL01 -i test.sql
Changed database context to 'PROD'.
Msg 7399, Level 16, State 1,
Server YMSQL01, Procedure V_C_Prod, Line 3 The OLE DB provider
"Microsoft.ACE.OLEDB.12.0" for linked server "C_PROD" reported an
error. The provider did not give any information about the error.
Msg 7303, Level 16, State 1, Server YMSQL01, Procedure V_C_Prod, Line 3
Cannot initialize the data source object of OLE DB provider
"Microsoft.ACE.OLEDB .12.0" for linked server "C_PROD".
As you can see, it seems that I cannot query on a view. This view is from a linked server which is connected to an Excel file (located on server B). I have installed the same ODBC driver on server B but I get the same error.
My SQL script:
Use PROD
Go
Merge dbo.conc AS t
using V_C_Prod as s
ON (t.CodeComptable=s.[Code Comptable])
WHEN MATCHED THEN UPDATE SET
t.[Marque]=s.[Marque]
,t.[CodeHolding] = s.[Code HOLDING]
,t.[Email1]=s.[Email Principal]
,t.[CP]=s.[CP]
,t.[Ville]=s.[Ville]
WHEN NOT MATCHED
THEN INSERT VALUES (
s.[Marque]
,s.[Code HOLDING]
,s.[Code Comptable]
,s.[Email Principal]
,s.[CP]
,s.[Ville];
Go
How can I solve this issue?
I'm trying to import large amount of data from an Oracle database using a Linked Server on MS SQL 2005.
Here's the OPENQUERY command.
SELECT * from OPENQUERY(HRDEV9,
'SELECT EMPLOYEE_ID
,EMPLOYEE_NAME
,TO_CHAR(BIRTHDATE,''yyyy-mm-dd'') AS BIRTHDATE
FROM SYSADM.PS_EMPLOYEES')
I have not included all the columns for the sake of keeping my example simple, I have around 180 columns and 75000 rows to import.
This is the error I'm getting when I execute the query:
OLE DB provider "OraOLEDB.Oracle" for linked server "HRDEV9" returned
message "Not enough storage is available to complete this operation.".
Msg 7399, Level 16, State 1, Line 1 The OLE DB provider
"OraOLEDB.Oracle" for linked server "HRDEV9" reported an error. The
provider ran out of memory.
Msg 7372, Level 16, State 4, Line 1 Cannot
get properties from OLE DB provider "OraOLEDB.Oracle" for linked
server "HRDEV9".
I have enabled autogrowth, and set the unrestricted file growth for both Data and Log files.
I have tried importing only 10 rows with the Oracle ROWNUM but still getting the same error.
Thank you for your time.
Try importing data from Oracle into CSV and then load it into MS SQL.
Sorry for pointing you to my blog, but here is how to get data fast from Oracle.
I'm posting this to help others with the same issue.
Apparently this is a bug confirmed by Microsoft. The error message occurs if the linked table contains a column of type NUMERIC.
The workaround is to re-create the linked server to use the Microsoft OLE DB Provider for ODBC (MSDASQL).
Here are two ways you can work around the behavior:
Use the ODBC driver for ORACLE that is provided by Microsoft:
EXEC sp_addlinkedserver #server = 'ORACLEODBC', #srvproduct = 'MSDASQL', #provider = 'MSDASQL',
#provstr = 'DRIVER={Microsoft ODBC for Oracle};SERVER=MyOracleServer;UID=USERNAME;PWD=Password;'
go
sp_addlinkedsrvlogin 'ORACLEODBC', false, NULL, 'USERNAME', 'Password'
-OR-
Use the ODBC driver for ORACLE that is provided by ORACLE:
EXEC sp_addlinkedserver #server = 'ORACLEODBC', #srvproduct = 'MSDASQL', #provider = 'MSDASQL',
#provstr = 'DRIVER={ORACLE ODBC DRIVER};SERVER=MyOracleServer;UID=USERNAME;PWD=Password;DBQ=ORACLE805;'
go
sp_addlinkedsrvlogin 'ORACLEODBC', false, NULL, 'USERNAME', 'Password'
Hope this helps.
I have set up a linked server from SQL Server 2008 R2 to an Excel spreadsheet, from which I read the contents in to a table, for comparison during an import.
The spreadsheet is held on a network share from an application server.
Basically, this works perfectly on the SQL Server when I run:
SELECT * FROM SpreadsheetLink...[CONTENTS$]
However, as I now need to schedule this, I need to create an SSIS package on the application server, which runs the same query.
So now, whenever I try to do this though (either by writing the script in to SSIS or by logging in to SQL Server Mgmt Studio on the App server and then opening an SQL connection to the SQL Server and querying directly) I get an error:
Msg 7399, Level 16, State 1, Line 1
The OLE DB provider "Microsoft.ACE.OLEDB.12.0" for linked server "SpreadsheetLink" reported an error. The provider did not give any information about the 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 "SpreadsheetLink"
I first wondered whether I had forgotten to install OLEDB12.0 on the application server, but it is there.
I next wondered whether it was a permissions issue, so I added the EVERYONE group, with "Full Control" to the folder containing the spreadsheet and also ensured that the account that I am both logged in with and running the query as is an administrator on both the SQL server and the Application Server.
I also checked that the account was a member of the Distributed COM user group on both servers (it was).
Additional info:
I have tried several things, but it still fails.
I added the following
sp_configure 'show advanced options', 1
GO
RECONFIGURE
GO
sp_configure 'Ad Hoc Distributed Queries', 1
GO
RECONFIGURE
I then re-tested, but got the same results (success from the local SQL server, failure from the other server).
Next, I tried creating a different query, referring to the spreadsheet directly by path, rather than by Link-name, but that resulted in exactly the same outcome:
SELECT * INTO TargetTableName FROM OPENROWSET('Microsoft.ACE.OLEDB.12.0',
'Excel 12.0;Database=\\SERVER_NAME\PATH\fileName.xls;HDR=YES',
'SELECT * FROM [sheetName$]')
I also applied all of the suggestions in the following page:
http://visakhm.blogspot.co.uk/2013/12/how-to-solve-microsoftaceoledb120-error.html. But still no joy.
I have a problem with this query:
UPDATE Provinces
SET Provinces.DefaultName=T2.Defaultname
FROM Provinces
INNER JOIN
OPENROWSET('Microsoft.Jet.OLEDB.4.0',
'Excel 8.0;Database=C:\provinces.xlsx;HDR=YES',
'SELECT Code, Defaultname FROM [Arkusz1$]') T2
On Provinces.Code = t2.Code
WHERE Provinces.Code = T2.Code
I get error:
Msg 7399, Level 16, State 1, Line 1
The OLE DB provider "Microsoft.Jet.OLEDB.4.0" for linked server "(null)" reported an error. The provider did not give any information about the 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)".
What is the source of this error, and how can I modify the SQL statement?
There are several possible causes of this detailed here: Linked Server using Microsoft.Jet.OLEDB.4.0 problem.
A likely is cause is file system permissions of the temp directory for the sql service login for whoever is accessing that linked server: C:\Documents and Settings\(sql login name)\Local Settings\Temp
That is permission denied error. Follow:
How to import data from Excel to SQL Server
How to use Excel with SQL Server linked servers and distributed queries
Note If you are using SQL Server 2005, make sure that you have enabled the Ad Hoc Distributed Queries option by using SQL Server Surface Area Configuration.
sp_configure 'Ad Hoc Distributed Queries', 1