Wrox Programmer Forums
|
SQL Server 2000 General discussion of Microsoft SQL Server -- for topics that don't fit in one of the more specific SQL Server forums. version 2000 only. There's a new forum for SQL Server 2005.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the SQL Server 2000 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old February 28th, 2006, 12:14 PM
Registered User
 
Join Date: Feb 2005
Posts: 9
Thanks: 0
Thanked 0 Times in 0 Posts
Default OPENROWSET problem

I'm trying to export data from a table into an Excel spreadsheet using this code

Use Northwind
GO
insert into OPENROWSET('Microsoft.Jet.OLEDB.4.0',
'Excel 8.0;Database=C:\testing.xls;',
'SELECT OrderID, CustomerID FROM [Sheet1$]') select OrderID, CustomerID from Orders
GO

It returns this error:

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: Unspecified error]
OLE DB error trace [OLE/DB Provider 'Microsoft.Jet.OLEDB.4.0' IDBInitialize::Initialize returned 0x80004005: ].

I set up the spreadsheet with "OrderID" in cell A1 and "CustomerID" in cell B1.
Any help would be appreciated.

Thanks


 
Old February 28th, 2006, 12:19 PM
Authorized User
 
Join Date: Sep 2005
Posts: 95
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi,
It should be
Use Northwind
GO
insert into Orders -- are you trying to insert into orders???
select OrderID, CustomerID from OPENROWSET('Microsoft.Jet.OLEDB.4.0',
'Excel 8.0;Database=C:\testing.xls;',
'SELECT OrderID, CustomerID FROM [Sheet1$]')
GO

you can comment out the insert to get the resultset only
select * from OPENROWSET('Microsoft.Jet.OLEDB.4.0',
'Excel 8.0;Database=C:\testing.xls;',
'SELECT OrderID, CustomerID FROM [Sheet1$]')
GO




------------------------------------------ http://sqlservercode.blogspot.com/
 
Old February 28th, 2006, 12:28 PM
Registered User
 
Join Date: Feb 2005
Posts: 9
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I'm trying to insert data into the spreadsheet. (i.e. export out of SQL Server into Excel)

 
Old February 28th, 2006, 12:33 PM
Authorized User
 
Join Date: Sep 2005
Posts: 95
Thanks: 0
Thanked 0 Times in 0 Posts
Default

you will have to use DTS for that

------------------------------------------ http://sqlservercode.blogspot.com/





Similar Threads
Thread Thread Starter Forum Replies Last Post
Openrowset DARSIN SQL Server 2000 0 September 22nd, 2005 08:04 AM
OPENROWSET ritag SQL Server 2000 3 June 23rd, 2004 09:50 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.