OPENROWSET And EXCEL

Nov 7, 2006

I having an excel file called TEST.XLS (in c: drive) which has 3 columns (c0,c1,c2) & 8 rows
c0 c1 c2
1 a A
2 b B
3 c C
4 d D
5 e E
6 f F
7 g G
8 h H

In sql server i have one table called TEST which has three columns
c0 char(10)
c1 char(10)
c2 char(10)


when i runnig the following query

select *
into TEST from openrowset('Microsoft.Jet.OLEDB.4.0',
'Excel 8.0;Database=C:TEST.xls;HDR=YES',
'select * from [Sheet1$]')



i am getting error like this

Server: Msg 7399, Level 16, State 1, Line 1
OLE DB provider 'Microsoft.Jet.OLEDB.4.0' reported an error.
[OLE/DB provider returned message: The Microsoft Jet database engine could not find the object 'Sheet1$'. Make sure the object exists and that you spell its name and the path name correctly.]
OLE DB error trace [OLE/DB Provider 'Microsoft.Jet.OLEDB.4.0' IColumnsInfo::GetColumnsInfo returned 0x80004005: ].

Version : Sql server 2000 & Excel 2002

Anybody having any idea why this error occuring?
thanks in advance...
Philkos

View 2 Replies


ADVERTISEMENT

OPENROWSET To Excel

Jan 14, 2007

Hi Anyone I am new member and happy to be here.

I am having trouble exporting the correct data from sql server to an excel spreadsheet using 'OPENROWSET'

The problem is that although the data from my sql table is say :
'a',1,2,3 , the excel spreadsheet sees the data as :
'a','1,'2,'3 ..1,2,3 are of course numbers NOT text, its just that the driver has put a single appostraphy before the number !

I know there is a bug with the ISAM driver but has anyone managed to solve this or has anyone have any alternatives ?

best regards

Reza

R Khan

View 3 Replies View Related

Openrowset And Excel

Apr 17, 2007

I'm doing an openrowset query on an excel sheet. (Using SQL Server 2005) Everything works great, except that I have one column that has both numeric and text data in the spreadsheet. The query returns that column as datatype varchar but puts nulls in the rows that have numeric data in the spreadsheet.

Any suggestions?

I run:

select *
from openrowset('microsoft.jet.oledb.4.0',
'Excel 8.0;database=[filepathandname],
'select * from [Sheet1$A4:G5000]')

on spreadsheet data that looks like:

Model_id Model_name
. . .
123 t4556
124 x225
125 455
. . .

and get something like . . . .

Model_id Model_name
. . .
123 t4556
124 x225
125 NULL
. . .

View 1 Replies View Related

OpenRowSet With Excel DENIED

Oct 7, 2005

Same with OpenDataSource. SQL 2000, logged in as non-SA.Getting message:Ad hoc access to OLE DB provider 'Microsoft.Jet.OLEDB.4.0' has beendenied. You must access this provider through a linked server.Can run with SQLOLEDB with connection string to same server(obviously), but when trying to access an Excel file, get the messageabove.It appears that the file name given in the connection string to Excelis with respect to the SQL server, so I have used UNC names to thefile. Nothing.Want to avoid DTS when it's a table that I need and can't use a linkedserver because it's always a one time thing.Any tips appreciated!

View 2 Replies View Related

Openrowset Excel 2007

Jul 31, 2007

Haven't been able to find much information on using openrowset with excel 2007 xlsx files. I've tried the following with no success so far.

SELECT * FROM OPENROWSET('Microsoft.ACE.OLEDB.12.0',
'Excel 12.0 Xml;Database=\serverfolderfile.xlsx;HDR=No;IMEX=1',
'SELECT f1 FROM [Raw Keywords$] WHERE f1 IS NOT NULL')

If anyone knows the correct way to do this please tell me.

View 3 Replies View Related

How To Query An Excel File By Using Openrowset

Mar 1, 2007

Hi everyone,

I'm trying to query an excel file and I get a mistake. The query is as follows:

SELECT * FROM OPENROWSET('Microsoft.Jet.OLEDB.4.0',
'Excel 8.0;Database=C:ExcelFile.xls', 'select * from Sheet1')

and I get the following error message:

Server: Msg 7399, Level 16, State 1, Line 1
OLE DB provider 'Microsoft.Jet.OLEDB.4.0' reported an error.
[OLE/DB provider returned message: The Microsoft Jet database engine could not find the object 'Book1'. Make sure the object exists and that you spell its name and the path name correctly.]
OLE DB error trace [OLE/DB Provider 'Microsoft.Jet.OLEDB.4.0' IColumnsInfo::GetColumnsInfo returned 0x80004005: ].

I'm thanking any help that you can give.

Thanks,

Oscar.

View 7 Replies View Related

T-SQL (SS2K8) :: Access EXCEL Using OPENROWSET

May 22, 2014

I'm trying to access Excel file from SQL Server management studio using OPENROWSET using the below query but getting the error listed below.

Query:
SELECT *
FROM OPENROWSET('Microsoft.ACE.OLEDB.12.0',
'Excel 12.0 Xml;HDR=YES;Database=E:TestFilesExcelFile.xlsx',
'SELECT * FROM [Sheet1$]'
)

Error:
Msg 7415, Level 16, State 1, Line 2
Ad hoc access to OLE DB provider 'Microsoft.ACE.OLEDB.12.0' has been denied. You must access this provider through a linked server.

View 9 Replies View Related

Can Not Access Excel File Using OpenRowset

Aug 8, 2007



I am using SQLServer 2005 SP2. I enabled the Ad Hoc Distributed Queries and DisallowAdhocAccess registry option is explicitly set to 0. Query is working fine when I remote desk to the server and execute when I run same query from my workstation I am getting following 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)".


Any help is appreciated.
Thanks
--
Farhan

View 8 Replies View Related

Delete Data In Excel Using Openrowset?

Feb 23, 2008

Hello,
I would like to delete all data from an excel sheet except the headers row.
Is there any way to do this using Openrowset with JET or something like that?
Thanks
Philippe

View 26 Replies View Related

OPENROWSET ( CAN WE CREATE FILE WITHOUT EXCEL TEMPLATE??)

Mar 20, 2008

insert into OPENROWSET('Microsoft.Jet.OLEDB.4.0', 'Excel 8.0;Database=D: esting.xls;', 'SELECT * FROM [SheetName$]') select * from pubs.dbo.authors
 
I am using similiar query to above to create a excel file, however for this to work, I need to create a template file which has the same columns as the authors table. Is there a way to NOT to define template columns , as I some times will not know which columns will be available... as teh query is dynamic....

View 4 Replies View Related

T-SQL (SS2K8) :: OPENROWSET When Excel Worksheet Name Is Unknown

Sep 7, 2011

I've created a stored procedure that accepts two arguments: the name of an Excel workbook (@workbookBillRun), and the name of the first worksheet found in that workbook (@worksheetBillRun).

Through dynamic SQL, I'm able to construct a statement that pulls out data.

SELECT @sqlBillRun = '
SELECT [ACCTNUM], [INVNUM], [RECURRING], [NON RECURRING], [USAGE],[DISCOUNT],[TAXES]
FROM OPENROWSET (''Microsoft.ACE.OLEDB.12.0'', ''Excel 12.0;;Database=' +@workbookBillRun+ ';HDR=YES'',
''SELECT * from [' +@worksheetBillRun+ '$]'')'

The workbook name will always be known: when the user uploads the file, I change the name to match a certain pattern. Example: 2011-08 AUG.xlsx

However, I won't always know the worksheet name. The workbook *should* contain just one worksheet; and the worksheet *should* be named identically to the workbook (2011-08 AUG), but it may not be named as such. And if I pass an invalid worksheet name, the code above will fail.

I've created error handling to alert the user of an incorrectly named sheet. However, I was curious whether I could extract the name of the first worksheet in the workbook from within T-SQL.

View 6 Replies View Related

Export In Excel With Using OPENROWSET From Stored Procedure

Nov 22, 2007



Hi
I am Utarsh Gajjar.
I am working on SQL Server 2005.

I have following Stored Procedure.

----------------------------------------------------------------------------
set ANSI_NULLS ON
set QUOTED_IDENTIFIER ON
GO

ALTER PROCEDURE [dbo].[ExportInExcel]
@QueryString VarChar(8000) =''
AS
BEGIN TRY

INSERT INTO OPENROWSET('Microsoft.Jet.OLEDB.4.0', 'Excel 8.0;Database=C:Customers.xls;IMEX=1','SELECT * FROM [Sheet1$]')
EXEC (@QueryString )


END TRY
BEGIN CATCH
DECLARE @ErrorMessage VARCHAR(8000);
DECLARE @ErrorSeverity INT;
DECLARE @ErrorState INT;

SELECT @ErrorMessage = ERROR_MESSAGE(),
@ErrorSeverity = ERROR_SEVERITY(),
@ErrorState = ERROR_STATE();

RAISERROR (@ErrorMessage, -- Message text.
@ErrorSeverity, -- Severity.
@ErrorState -- State.
);
END CATCH

-------------------------------------------------------------------------------

Error is

-------------------------------------------------------------------------------
(0 row(s) affected)

Msg 50000, Level 16, State 2, Procedure ExportInExcel, Line 31
The requested operation could not be performed because OLE DB provider "Microsoft.Jet.OLEDB.4.0" for linked server "(null)" does not support the required transaction interface.

(1 row(s) affected)



how can i solve this problem?


Thanks in advance.

View 16 Replies View Related

Import Excel-File (OPENROWSET) On X64 SQL Server

Jan 7, 2008

Hi, recently I encountered the following problem:
I tried to execute a stored procedure on the newly installed SQL 2005 Server (now on x64 Win Server 2003) which imports an Excel-File into a DB table.
We use OPENROWSET to access the Excel data. But I recognized this is dependent on Jet OLE DB which seems is not available for x64 windows.

Is there another way to import excel data using a stored procedure.

thank you in advance, rene

View 12 Replies View Related

OpenRowSet And OpenDataSource Fail On Production To Open Excel Data

Jun 26, 2006

The following statement fails when using SQL Analyzer under sa but works on all of our development and staging server. All are SQL Server 2005 SP1. We upgraded production over the weekend from SQL Server 2000, creating a new instance machinenameSQL2005.

SELECT *

FROM OPENROWSET('Microsoft.Jet.OLEDB.4.0',

'Excel 8.0;Database=d:data est.xls',

'SELECT * FROM [Sheet1$]')

The error we are getting only in prodcution is:

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)".

Any help seriously appreciated,



Tronn

View 44 Replies View Related

Passing A Variable To A Linked Query (OPENROWSET For Excel Syntax)

May 11, 2007

Hello,

I responded to a very old discussion thread & afraid I buried it too deep.

I have studied the article: How to Pass a Variable to a Linked Query (http://support.microsoft.com/default.aspx?scid=kb;en-us;q314520)



but I have not gotten all the ''''' + @variable syntax right.



Here is my raw openrowset with what I am aiming at.






Code Snippet

-- I want to use some kind of variable, like this to use in the file:

DECLARE @FIL VARCHAR(65)

SET @FIL = 'C:company foldersDocumentationINVENTORY.xls;'

--

SELECT FROM OPENROWSET('MSDASQL', 'Driver=Microsoft Excel Driver (*.xls);DBQ=C:company foldersDocumentationINVENTORY.xls;', 'SELECT * FROM [Inventory$]')

AS DT



Anyone game? Many thank-yous, in advance.



Kind Regards,

Claudia.

View 1 Replies View Related

SQL 2012 :: OPENROWSET To Read In Data From Excel 2010 File (XLSX)

Jun 12, 2015

I have a test server (TEST1) running SQL 2012 and Windows 2012R2. One of the developers wants to use OPENROWSET to read in data from an Excel 2010 file (an xlsx file).

I have loaded the Microsoft Drivers in "AccessDatabaseEngine_64.exe" and enabled the Ad Hoc Distributed Queries option in SQL.

This is the sample code we are working with:

SELECT
X.MEMBID
FROM OPENROWSET(
'MSDASQL',
'Driver={Microsoft Excel Driver (*.xls, *.xlsx, *.xlsm, *.xlsb)};DBQ=etworkserverFolder1Folder2MEMBIDs.xlsx',
'SELECT * FROM [Sheet1$]'
) AS X

I can run the sample query from my laptop with SSMS (I have admin rights) and I can also run it as SA from my laptop. So all is good, right?

But if I RDC into TEST1, I cannot run the query. I get this error:

OLE DB provider "MSDASQL" for linked server "(null)" returned message "[Microsoft][ODBC Excel Driver] Your network access was interrupted. To continue, close the database, and then open it again.".
OLE DB provider "MSDASQL" for linked server "(null)" returned message "[Microsoft][ODBC Excel Driver]General error Unable to open registry key Temporary (volatile) Ace DSN for process 0x574 Thread 0xb74 DBC 0x1d07f08 Excel'.".
OLE DB provider "MSDASQL" for linked server "(null)" returned message "[Microsoft][ODBC Excel Driver]General error Unable to open registry key Temporary (volatile) Ace DSN for process 0x574 Thread 0xb74 DBC 0x1d07f08 Excel'.".
Msg 7303, Level 16, State 1, Line 1
Cannot initialize the data source object of OLE DB provider "MSDASQL" for linked server "(null)".But wait! It gets better.

I can run the query as SA from TEST1.

And of course, the developer can't run it either.

And it works fine in the production server.

I'm thinking the basics are there but something isn't right in some permission somewhere.

View 9 Replies View Related

Any Idea Why OpenRowSet To Open Excel File Doesn't Work Well In SQL 2005?

Mar 3, 2007

Maybe it worked once, but in most time it doesn't work, query like below

select top 10 *
from OpenRowSet('microsoft.jet.oledb.4.0','Excel 8.0;hdr=yes;database=\ws8webablefilessitefiles4000010
eibcactive.xls',
'select * from [crap2$]')


I got error

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 the same query can run without any problem on a SQL 2000 server run on a server in the same network.

Any idea?

View 12 Replies View Related

Recurring Issue - OPENROWSET For Excel Query Stops Working , Cured By Restart Of SQL Server

May 25, 2007

Hi,

I am having a recurring issue that involves a stored proc using OPENROWSET to query an excel file. I used the surface area config to enable this on the server, and made sure that is still set. After an undetermined amount of time, the OPENROWSET query starts failing with this message:

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)".

I corrected this previously by restarting the SQL server, but not before I checked permissions, the excel file itself, etc, and that was the last thing to try.

I am using SQL 2005 with SP1 installed - my primary approach to tackling this issue is to install the SP2, but I did not find this bug referenced in the fixes, and was wondering if anyone else had further insight.

Thanks,
Darrell Young

View 3 Replies View Related

Openrowset

Nov 20, 2002

How come when I run the script:
select * from openrowset ('MSDASQL', 'Driver=Microsoft Excel Driver (*.xls);DBQ=\inawwwpro01d$atrUploadACK102.xls' , 'select * from [sheet1$]') from Server A I get a RESULT, and when I run from Server B I get the following error:
Ad hoc access to OLE DB provider 'MSDASQL' has been denied. You must access this provider through a linked server.
Both servers are using IDENTICAL SQL Logins.
Both servers are SQL 2000 SP2.

When I run the script on Server B logged in as SA, then I get a Result!!!

View 4 Replies View Related

OpenRowset

Mar 7, 2005

I can successfully retreive data using:

Declare @Path varchar(100)
Declare @CommandString varchar(100)
Set @Path = ''
Set @CommandString = 'Select * from [myTable.csv]'

EXEC('SELECT *
from OpenRowset(''MSDASQL'', ''Driver={Microsoft Text Driver (*.txt; *.csv)};DefaultDir=\myServermySharedb' + @Path + ';'',''' + @CommandString + ''')')

Does anyone know an easy method to get column names into a table using OpenRowset :confused:

View 1 Replies View Related

Openrowset

Jan 14, 2008

how can i use openrowset. my aim is to develop a import and export data from diff. server . i am using vb.net 2003 , sql sever 2000.
when i am running
openroeset function with window or server authontication it is showing
'OLE DB provider 'SQLOLEDB' reported an error. The provider did not give any information about the error.


anybuddy help me , pls. tell me the right solution.

View 3 Replies View Related

OPENROWSET

Aug 21, 2007

Hi!
I decided to use OPENROWSET for importing data from an excel file into a sql table.When I import the data,I have a problem:

-not all the data is imported to my sql table
-some values in the sql table are different from the ones in the excel file
For example,a value that in the excel file is:87878787 will be in the SQL table:8.78788e+007.

Can somebody pls tell me what's the problem

View 1 Replies View Related

OpenRowSet BUG?

Jul 23, 2005

Hi Folks,I am trying to load data from a table in MS Access to SQL Server 2000using T-SQL OPENROWSET. When I select data from the remote database (MSAccess) using SQL Query analyzer, the columns do NOT appear in the sameorder as seen in Access directly.For e.g. if Access table has columns Cy, Cx, Cz the output in Queryanalyzer appears as Cx, Cy, Cz. It appears to arrange the fieldsalphabetically. This causes problems when I do a 'insert into select *from' as the field definitions do not agree.Is this a bug or is there a setting in Access/SQL which I am missing?Also, please let me know if there is a workaround for this issue.Thanks in advance!Bhaskar

View 3 Replies View Related

OPENROWSET Only Returns First Row

Oct 15, 2014

I've got some text files that I need to read and make some calculations, before inserting data into a table.

When I use:

Code:
select BulkColumn as txt from openrowset(BULK 'c:Tempdata35.txt', SINGLE_NCLOB) as text

It only retrieves the first row. How can I select all the lines in the file?

View 1 Replies View Related

OPENROWSET Error

Mar 25, 2004

I am trying to use OPENROWSET in SQL Server to connect to my Access database, but I keep getting the following error:

OLE DB provider 'Microsoft.Jet.OLEDB.4.0' reported an error.
[OLE/DB provider returned message: The Microsoft Jet database engine cannot open the file 'X:SetupDatabaseKDB_X2.mdb'. It is already opened exclusively by another user, or you need permission to view its data.]
OLE DB error trace [OLE/DB Provider 'Microsoft.Jet.OLEDB.4.0' IDBInitialize::Initialize returned 0x80004005: ].

I have checked the database, it is not in use, and there is no password set on the database that would prevent me from getting access to it. Any ideas? Here's the syntax I'm using:

SELECT *
FROM OpenRowset('Microsoft.Jet.OLEDB.4.0',
'X:SetupDatabaseKDB_X2.mdb';'Admin';'', subPSEL_PList))

View 3 Replies View Related

XML RELATED OPENROWSET

Jun 20, 2008

select @xml = bulkcolumn from openrowset(bulk 'C:Documents and
SettingsKasiDesktopewsrss.xml' , single_blob) as channel



here after bulk instead of giving path, we have to give parameter so that the paramter takes the value from the table.

the tables contains paths of xml files

View 2 Replies View Related

Openrowset Views

Nov 30, 2007

Hi I have a table like:

LIB TABLENAME TABLEDESCR FIELDNAME FIELDDESCR
BISxxSETALPA0AsometableBS12A0somefield
BISxxSETALPA0AsometablePERCA0somotherfield
BISxxSETALPA1AsomeothertableCMPNA1somefield2
BISxxSETALPA1AsomeothertableMERIA1someotherfield2
BISFFBUAALPA1AanothertablePAARSsomefield3

and would like to create views for each distinct table, using openrowset.
An added complexity is that the library name depends on the company code (i.e. BISxxSET.ALPA0A turns to BIS03SET.ALPA0A for company 03 whereas BSFFBUA.ALPA1A remains intact).

Thanks in advance

Kyriakos

View 4 Replies View Related

OPENROWSET Parms'

Mar 14, 2008

Hi

I've got the following code that uses OPENROWSET but I need to paramaterise the filepaths and its not working:

set ANSI_NULLS ON
set QUOTED_IDENTIFIER ON
GO

BEGIN

declare @dataareaid as varchar(3)
declare @configpath as varchar(100)
declare @configfile as varchar(100)
declare @configformatfile as varchar(100)


set @configfile = 'C:ConfigFileConfigFileMot.txt'
set @configformatfile = 'C:ConfigFileConfigFormatFile.txt'

print @dataareaid
print @configpath
print @configfile
print @configformatfile

set @dataareaid = (SELECT dataareaid
FROM OPENROWSET( BULK @configfile , FORMATFILE = @configformatfile
) AS a)


select *
FROM AX.[P2].dbo.Dimensions Dim
WHEREDim.dataareaid = @dataareaid

END

View 3 Replies View Related

Openrowset And Mdb -Files

Jul 23, 2005

Hy Forum !I tried to do somsthing like this:CREATE PROCEDURE dbo.maches ASselect * from openrowset('Microsoft.Jet.OLEDB.4.0','C: empFehler.mdb'; 'Administrator'; ' ' , Fehlerliste)This user 'Admistrator' exists and there is no password for the .mdbfile. In the end the syntax checker tells me:Fehler 7303: Datenquellenoblekt von OLE DB Provider'Microsoft.Jet.OLEDB.4.0' konnte nicht initialisiert werden.I'm using Access 2000 and SQL Server 7.Thank you

View 1 Replies View Related

XQuery Vs OpenRowset

Apr 5, 2006

Please let me know the advantages and disadvantages of XQuery vsOpenRowSet in SQL Server 2005. Which would be better?Regards,Shilpa

View 1 Replies View Related

Using OPENROWSET With An IP Address

Jan 11, 2007

Hi

I've got an openrowset query that works perfectly if I enter the computer name, but it fails when I enter the IP address.

Is there a setting somewhere that I need to enable to make this happen?

Thanks in advance

View 5 Replies View Related

Use OPENROWSET With Web Address?

Aug 28, 2006

I have an excel file on a web server on a different location to the sql server. I want to use OPENROWSET to query the excel file, but it doesn't seem to like using a URL.

Is this the case, or am I doing it wrong? Works fine when I use a local address (eg c:excelfile.xls) when testing locally, but I need to use a URL in production.

SELECT * FROM OPENROWSET('Microsoft.Jet.OLEDB.4.0','Excel 8.0;Database=http://mydot.com/excelfile.xls','SELECT * FROM [page1$]')

View 1 Replies View Related

Openrowset Error

Jul 22, 2006

I have an access database from which i want to use data in sql server if a table has column with values like 6.32404E-244 i've got an error message like:

OLE DB provider 'Microsoft.Jet.OLEDB.4.0' for linked server '(null)' returned invalid data for column '[Microsoft.Jet.OLEDB.4.0].Stoc_Max'

a simple select like 'SELECT * FROM OPENROWSET(.....,table) gives me this error.

View 3 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved