dbTalk Databases Forums  

Help a newb (issue with excel, ms access and SQL Server)

comp.databases.ms-sqlserver comp.databases.ms-sqlserver


Discuss Help a newb (issue with excel, ms access and SQL Server) in the comp.databases.ms-sqlserver forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
joaotsetsemoita@gmail.com
 
Posts: n/a

Default Help a newb (issue with excel, ms access and SQL Server) - 10-08-2007 , 05:20 AM






hello everyone.

I recently changed the database of a project from Ms Access to SQL
server and had to make a lot of adjustments but there's one here where
I can't figure it out how to do this in SQL server.

I was using the following to create an excel file based on the select
from Ms Access.

"SELECT * INTO [Excel 8.0;Database=" & server.mapPath("../documents/
example.xls].[sheet1]")&" FROM (SELECT * FROM TABLE1)"

This was working fine until the bd was changed to Ms Server 2005 where
it occurs an error. I will post the error even if its kind useless.

Error:
Microsoft OLE DB Provider for SQL Server error '80040e14'
Incorrect syntax near ')'.

As I said, the exact same code works fine in access. Any sugestion how
to get this solved??

I know some turn arounds like create a content/type x-excel page and
this allow the user to save the file, but I really need is to create
the file .XLS on the disk to allow the user to download whenever they
want.

Any help is highly appreciated.

Thanks in advance

Joao


Reply With Quote
  #2  
Old   
Erland Sommarskog
 
Posts: n/a

Default Re: Help a newb (issue with excel, ms access and SQL Server) - 10-08-2007 , 05:03 PM






(joaotsetsemoita (AT) gmail (DOT) com) writes:
Quote:
I recently changed the database of a project from Ms Access to SQL
server and had to make a lot of adjustments but there's one here where
I can't figure it out how to do this in SQL server.

I was using the following to create an excel file based on the select
from Ms Access.

"SELECT * INTO [Excel 8.0;Database=" & server.mapPath("../documents/
example.xls].[sheet1]")&" FROM (SELECT * FROM TABLE1)"

This was working fine until the bd was changed to Ms Server 2005 where
it occurs an error. I will post the error even if its kind useless.

Error:
Microsoft OLE DB Provider for SQL Server error '80040e14'
Incorrect syntax near ')'.

As I said, the exact same code works fine in access. Any sugestion how
to get this solved??
Well, I can explain why you get the error: there are tons of syntax
differences betweeen Access and SQL Server. There is a SELECT INTO
command in SQL Server, but I can't imagine that you can create
Excel files with it.

You can access Excel file with help of OPENROWSET, but I have don't
this myself. I believe there are some examples in Books Online.

Best approach to do this client side. In SQL Server you would have to
do this in a CLR procedure. Of if you are on SQL 2000 with help of
sp_OAmethod and friends, which is no fun exercise at all.


--
Erland Sommarskog, SQL Server MVP, esquel (AT) sommarskog (DOT) se

Books Online for SQL Server 2005 at
http://www.microsoft.com/technet/pro...ads/books.mspx
Books Online for SQL Server 2000 at
http://www.microsoft.com/sql/prodinf...ons/books.mspx


Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.