September 6, 2007 at 11:29 am
I want to do what I think should be a pretty easy task. I have a data set in SQL Server and I want to schedule a job to once a day push updated data to an Excel file I have on my server. I just need it to do a simple overwrite of the existing Excel file.
I am using SQL Server 2005 client with a SQL Server 2000 server. I would rather not use DTS or SSIS because of that combo. I'm hoping there is some code I can put in a sproc that would get this job done and then I can just schedule the sproc as a job that runs nightly.
TIA.
September 6, 2007 at 1:56 pm
A warning up front, this solution is not good for security reasons because you have to have xp_cmdshell enabled, but if you already have that procedure enabled, you can do the following to bcp your data out:
if you can't have xp_cmdshell enabled, you can schedule a windows task to bcp your data out.
declare @bcp varchar(500)
declare @select varchar(500)
declare @path varchar(500)
set @path = '"\\someserver\somefolder\somefile.xls"'
SET @Select = '"SELECT * FROM tablename"'
set @bcp = 'bcp ' + @select + ' queryout ' + @path + ' -S sqlservername -T -w'
exec master..xp_cmdshell @bcp
September 6, 2007 at 6:02 pm
Or...
Create a view or a reporting table and use Excel's "Get External Data".
--Jeff Moden
Change is inevitable... Change for the better is not.
Viewing 3 posts - 1 through 2 (of 2 total)
You must be logged in to reply to this topic. Login to reply