Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
Author |
Topic |
bbasir
Yak Posting Veteran
76 Posts |
Posted - 2008-03-18 : 15:11:07
|
I am trying to create an excel file using openrowset in ms sql 2000.but i get the following error when I try to create the file...Error 7399: OLE DB provider 'Microsoft.Jet.OLEDB.4.0' reported an error.Authentication failed.What can I do?-- here is my codeCreate PROCEDURE MCA_SP_CREATE_EXCEL @File_Name as varchar(50) = ''ASBEGINSET NOCOUNT ONdeclare @File_Name as varchar(50)DECLARE @Cmd varchar(1000)DECLARE @fn varchar(500)DECLARE @provider varchar(100)DECLARE @ExcelString varchar(100)-- New File Name to be createdIF @File_Name = ''Select @fn = 'C:\Test.xls'ELSESelect @fn = 'C:\' + @File_Name + '.xls'-- FileCopy command string formationSELECT @Cmd = 'Copy C:\Template.xls ' + @fn-- FielCopy command execution through Shell CommandEXEC MASTER..XP_CMDSHELL @cmd, NO_OUTPUT-- Mentioning the OLEDB Rpovider and excel destination filenameset @provider = 'Microsoft.Jet.OLEDB.4.0'set @ExcelString = 'Excel 8.0;Database=' + @fn-- Executing the OPENROWSET Command for copying the select contents to Excel sheet.exec('insert into OPENrowset(''' + @provider + ''',''' + @ExcelString + ''',''SELECT FirstName,LastName,Phone,Address,City,State,Zip FROM [Sheet1$]'') select au_fname as FirstName,au_lname as LastName,phone,address,city,State,Zip from authors')exec('insert into OPENrowset(''' + @provider + ''',''' + @ExcelString + ''',''SELECT StoreId, OrderNo, OrderDate, Quantity FROM [Sheet2$]'') select stor_id as StoreId,Ord_Num as OrderNo,Ord_Date as OrderDate,qty as Quantity from sales')SET NOCOUNT OFFEND |
|
rmiao
Master Smack Fu Yak Hacker
7266 Posts |
Posted - 2008-03-20 : 23:27:28
|
Tried run it without variables? |
|
|
|
|
|
|
|