Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Stored Procedure to open and save as an Excel Spreadsheet

4 views
Skip to first unread message

SAC

unread,
Dec 28, 2009, 3:02:27 PM12/28/09
to
I need help in how to make a stroed procedure which will open an existing
file and rename it witha different file extention.

Current file is an "excel" spreadsheet, but it's an html file. It has a xls
extention, but when I open it in Excel and then click save as, the file type
defaults to html. So, I'd like to open it and save as a file type of xls
and I need a stored procedure to do this.

How can I do this?

Thanks for your help.


Erland Sommarskog

unread,
Dec 28, 2009, 5:46:11 PM12/28/09
to
If you are on SQL 2005, you do it best from the CLR, although I don't
know exactly how much you can operate Excel from .Net.

If you are on SQL 2000, you would need to use the sp_OAxxx routines,
which is not really to recommend.

Overall, I would look for a different solution. SQL is not a general-
purpose language, and not really suitable for this task.

If this is something you want for your own convenience, VBscript or
Powershell are far better options.


--
Erland Sommarskog, SQL Server MVP, esq...@sommarskog.se

Links for SQL Server Books Online:
SQL 2008: http://msdn.microsoft.com/en-us/sqlserver/cc514207.aspx
SQL 2005: http://msdn.microsoft.com/en-us/sqlserver/bb895970.aspx
SQL 2000: http://www.microsoft.com/sql/prodinfo/previousversions/books.mspx

SAC

unread,
Dec 29, 2009, 10:20:39 AM12/29/09
to
I can do it in vb scrip, but how do I tie it into a job within sql? I need
it to run within a scheduled job.

Thanks for your help.

"Erland Sommarskog" <esq...@sommarskog.se> wrote in message
news:Xns9CEFF1CCF...@127.0.0.1...

Erland Sommarskog

unread,
Dec 30, 2009, 5:32:48 PM12/30/09
to
SAC (s...@somewhere.com) writes:
> I can do it in vb scrip, but how do I tie it into a job within sql? I
> need it to run within a scheduled job.

You can set up a job as an Active-X script. Just chose that from the
drop down for job type.

SAC

unread,
Feb 2, 2010, 12:31:39 PM2/2/10
to
Oh! Thanks!

"Erland Sommarskog" <esq...@sommarskog.se> wrote in message
news:Xns9CF1EF8C9...@127.0.0.1...
0 new messages