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.

 All Forums
 SQL Server 2000 Forums
 Import/Export (DTS) and Replication (2000)
 Error 7399 ( Openrowset ) Authentication failed

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 code

Create PROCEDURE MCA_SP_CREATE_EXCEL @File_Name as varchar(50) = ''
AS
BEGIN
SET NOCOUNT ON
declare @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 created
IF @File_Name = ''
Select @fn = 'C:\Test.xls'
ELSE
Select @fn = 'C:\' + @File_Name + '.xls'

-- FileCopy command string formation
SELECT @Cmd = 'Copy C:\Template.xls ' + @fn

-- FielCopy command execution through Shell Command
EXEC MASTER..XP_CMDSHELL @cmd, NO_OUTPUT

-- Mentioning the OLEDB Rpovider and excel destination filename
set @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 OFF
END

rmiao
Master Smack Fu Yak Hacker

7266 Posts

Posted - 2008-03-20 : 23:27:28
Tried run it without variables?
Go to Top of Page
   

- Advertisement -