May 2, 2009 at 12:02 am
HI,
I'm exporting data into an excel file by using OPENROWSET:
The code from the some sqlsite.
INSERT INTO OPENROWSET('Microsoft.Jet.OLEDB.4.0',
'Excel 8.0;Database=C:\testing.xls;',
'SELECT Name, Date FROM [Sheet1$]')
SELECT Name FROM msdb.dbo.sysjobs
But it is giving the error:
The OLE DB provider "Microsoft.Jet.OLEDB.4.0" for linked server "(null)" supplied invalid metadata for column "Name". The data type is not supported.
what is wrong with this query?
please help me out.
🙂
May 2, 2009 at 9:43 am
I didn't try but maybe it depends on the fact that column "name" of "model.dbo.sysjobs" is data type "SYSNAME" which is a user defined type.
Try to use CONVERT with type NVARCHAR(256).
Greets
Flo
May 2, 2009 at 10:38 am
First - does the Excel workbook exist in the path specified? If not .create it.
Second - does it have in Row 1 column names? If not, note the HDR=No;portion of the command. If it does have headers in row 1 then HDR=Yes;
I tested this modification of your code and it did not report any errors
INSERT INTO OPENROWSET('Microsoft.Jet.OLEDB.4.0',
'Excel 8.0;Database=C:\testing.xls;HDR=No;',
'SELECT * FROM [Sheet1$]')
SELECT Name FROM msdb.dbo.sysjobs
May 4, 2009 at 9:27 pm
hi,
thanks for ur answer, but
INSERT INTO OPENROWSET('Microsoft.Jet.OLEDB.4.0',
'Excel 8.0;Database=C:\testing.xls;HDR=No;',
'SELECT * FROM [Sheet1$]')
SELECT * FROM msdb.dbo.sysjobs
it is giving the error like
Insert Error: Column name or number of supplied values does not match table definition.
could u please help me.
🙂
December 8, 2009 at 11:04 am
This is a correct solution and it resolved my problem....
Viewing 5 posts - 1 through 4 (of 4 total)
You must be logged in to reply to this topic. Login to reply