import 2007 excel data into sql server 2012 - sql-server

While importing data from excel 2010 into SQL Server 2012 I am getting following error:
Msg 7399, Level 16, State 1, Line 1
The OLE DB provider "Microsoft.ACE.OLEDB.12.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.ACE.OLEDB.12.0" for linked server "(null)".
<
I am using following query:
SELECT * INTO dbo.headers
FROM OPENROWSET('Microsoft.ACE.OLEDB.12.0' ,'Excel 12.0;Database=C:\Users\ishu.bhardwaj\Desktop\02.xlsx;HDR=YES;IMEX=1' ,'SELECT * FROM [Sheet1$]')
Regards
Ishu Bhardwaj

Cause 1: You may receive this error if the Excel file is currently opened.
Solution 1: Close the Excel file if it is currently opened and try executing again.

Related

OPENROWSET From SQL to Oracle

i'm trying to connect from sql server to oracle server with OPENROWSET for fetch data.
this is my query:
SELECT a.*
FROM OPENROWSET(N'OraOLEDB.Oracle', N'Data Source=Myip:Port/dbname';'User Id=user';'Password=pass;',
'select * FROM view WHERE value = ''102030'' ') AS a;
sql return below error:
OLE DB provider "OraOLEDB.Oracle" for linked server "(null)" returned
message "ORA-12154: TNS:could not resolve the connect identifier
specified". Msg 7303, Level 16, State 1, Line 23 Cannot initialize the
data source object of OLE DB provider "OraOLEDB.Oracle" for linked
server "(null)".
how can i fix this ?
I used Linked Server for fetch data but oracle table not small and it takes a long time to execute.

SQL Msg 7399 and Msg 7303

Is it possible that the main problem is not in SQL or in my PC but in Main Server that I am using?
I tried Giving permission to Temp Folder.
I tried Logging on an account or as local system in MSSQLSERVER.
I tried changing AllowInProcess,DynamicParameters,AdHoc Distributed Queries, Show advance option.
I tried different codes or ways to figure out.
But all of these fail.
Msg 7399, Level 16, State 1, Line 2 The OLE DB provider
"Microsoft.ACE.OLEDB.12.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 2 Cannot initialize the data source
object of OLE DB provider "Microsoft.ACE.OLEDB.12.0" for linked server
"(null)".

Call Oracle function with ref cursor output in SQL Server linked server?

How do I need to call an Oracle function with ref cursor output in a SQL Server linked server?
I used this statement:
SELECT *
FROM OPENQUERY(oracle, 'select * from functionname(''N'',''2016-11-01'')')
but I get this error
OLE DB provider "OraOLEDB.Oracle" for linked server "oracle" returned message "ORA-00933: SQL command not properly ended".
Msg 7321, Level 16, State 2, Line 33
An error occurred while preparing the query "select * from functionname('N','2016-11-01')" for execution against OLE DB provider "OraOLEDB.Oracle" for linked server "oracle".
Any help?
Maybe this will help?
Calling an Oracle function from SQL Server Linked Server
EXECUTE (Query, Parameters) AT LinkedServerName

Error when executing SQL scripts with SQL Server authentication

I have some issue when executing scripts in SQL.
SELECT *
FROM OPENROWSET('Microsoft.ACE.OLEDB.12.0',
'Excel 8.0;Database=D:\Application\myExcel.xls;',
'SELECT * FROM [Sheet1$]')
When I login to SQL Server with Windows authentication, the script above runs successfully.
But when I login to SQL Server with SQL Server authentication (not sa account), the script throw this error:
Msg 7399, Level 16, State 1, Line 8
The OLE DB provider "Microsoft.ACE.OLEDB.12.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 8
Cannot initialize the data source object of OLE DB provider "Microsoft.ACE.OLEDB.12.0" for linked server "(null)".
Could anyone please tell me why and how to fix it?
I'm using SQL Server 2012 (x64), Windows Server 2012 R2.
Thank you very much.

Connect Oracle to SQL Server

I am trying to connect Oracle 9i database using SQL Management studio 2008.
I tried this but it doesn't work
EXEC sp_addlinkedserver 'OracleLinkedServer','Oracle','OraOLEDB.Oracle','TestDB';
EXEC sp_addlinkedsrvlogin 'OracleLinkedServer','false','SA','TestUsername','TestPassword';
I am able to create the linked server and it test correctly,
But when I execute this statement:
SELECT sysdate FROM OracleLinkedServer...dual;
...it gives an error:
Msg 7399, Level 16, State 1, Line 1
The OLE DB provider "OraOLEDB.Oracle" for linked server "OracleLinkedServer" reported an error. Provider caused a server fault in an external process.
Msg 7311, Level 16, State 2, Line 1
Cannot obtain the schema rowset "DBSCHEMA_TABLES" for OLE DB provider "OraOLEDB.Oracle" for linked server "OracleLinkedServer". The provider supports the interface, but returns a failure code when it is used.
You should UNCHECKED the Allow inprocess in OraOLEDB.Oracle provider under the Linked Servers node.

Resources