Insert Into Excel File From 64 Bit SQL 2008

Hello,

I have a stored procedure that uses the following code to insert into a pre existing excel file.

SET @mysql  =  'insert into OPENROWSET(' + char(39) + 'Microsoft.Jet.OLEDB.4.0' + char(39) + ','
 + char(39) + 'Excel 8.0;Database=' + @myexcelfile + ';' + char(39) + ','
 + char(39) + '
 SELECT *
 FROM [' + @mytable + ']' + char(39) + ')
 SELECT * FROM ' + @mytable

But am getting an error

Msg 7403, Level 16, State 1, Line 1
The OLE DB provider "Microsoft.Jet.OLEDB.4.0" has not been registered.

I understand that this is because there is no 64 bit OLEDB driver available.
I have read that I can install SQL 2005 Express 32 bit along side of SQL 2008 to work around this. But I would like to avoid doing that.

I have also read that the download available @

http://www.microsoft.com/downloads/details.aspx?FamilyID=000364db-5e8b-44a8-b9be-ca44d18b059b&displaylang=en

Does not remedy this problem as it only bridges OLE DB to ODBC. It does not bridge 64-bit to 32-bit. Which means that 32-bit OLE DB Providers, such as Jet, and 32-bit ODBC are still inaccessible to SQL Server 64-bit.

Are there any alternatives to get my code working without having to install another SQL server version etc?
SET @mysql  =  'insert into OPENROWSET(' + char(39) + 'Microsoft.Jet.OLEDB.4.0' + char(39) + ',' 
 + char(39) + 'Excel 8.0;Database=' + @myexcelfile + ';' + char(39) + ','
 + char(39) + '
 SELECT * 
 FROM [' + @mytable + ']' + char(39) + ') 
 SELECT * FROM ' + @mytable

Open in new window

bnrtechAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

nmcdermaidCommented:
You could run an SSIS package in 32 bit mode to do that.
0
TAB8Commented:
What you are doing with your code is connecting to Excel and trying to use it directly as a datasource ..  this will not be possible as Excel is a 32bit application and you are running 64bit sql .... "there is no fix to use 32 bit data source for 64 sql"
so your options
1, install sql2008 x64 - 32 bit .. then you can setup you Excel datasource
or
2, create an SSIS package to import the data from you .xls into a holding table on your sql server then you can query the data...  you could run you SSIS package every hour for example to update you SQL Table
0
nmcdermaidCommented:
Actually I think they are trying to insert into the worksheet.
0
10 Tips to Protect Your Business from Ransomware

Did you know that ransomware is the most widespread, destructive malware in the world today? It accounts for 39% of all security breaches, with ransomware gangsters projected to make $11.5B in profits from online extortion by 2019.

nmcdermaidCommented:
Actually I think they are trying to insert into the worksheet.
0
TAB8Commented:
would still have to use SSIS..    you cant directy connect from x64 sql to x32 excel
0
nmcdermaidCommented:
Yes,as I already stated in the very first post.
0
bnrtechAuthor Commented:
Hi nmcdermaid,

I had previously tried placing my command inside an SQL Exec Task within my SSIS package, but still get the same error. Perhaps I am following the wrong series of steps. Can you explain?
0
nmcdermaidCommented:
A SQL exec task still runs inside 64 bit SQL Server and therefore still will not find the driver. You need to develop an SSIS package from scratch using a data flow, and run the package as 32 bit process.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
TAB8Commented:
rename

C:\Program Files\Microsoft SQL Server\90\DTS\Binn\DTExec.exe to DTExec.x64

then copy

C:\Program Files (x86)\Microsoft SQL Server\90\DTS\Binn\DTExec.exe

to the first mentioned folder. It will run everything as 32-bit, but it will work
0
nmcdermaidCommented:
As you are using SQL 2008, see bottom of this page for an alternative method:
http://msdn.microsoft.com/en-us/library/ms141766.aspx
 
 
0
bnrtechAuthor Commented:
Hi TAB8,

Thank you for suggestion but I cannot follow through with it as there are existing packages that need to run in 64 bit mode.

nmcdermaid,

You are correct that I need to run the package as a 32bit process. I have been doing so by running dtexec via cmdshell with a full path to the 32 bit version. I'll try building from scratch and will let you know how it goes.
0
nmcdermaidCommented:
check out the link - there is no need to run as a cmdexec process anymore.  You can run a standard SSIS step and just tick 32 bit.
0
bnrtechAuthor Commented:
Hello again,

The SSIS step is not an option for me as many users need to be able to run this process at once. However the dtexec 32bit is working well so far. If I run into any issues ill start another thread. Thanks for all the help.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft SQL Server 2008

From novice to tech pro — start learning today.