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
 SQL Server Development (2000)
 Is it Possible - Schedule SP w Param save to file

Author  Topic 

ft
Starting Member

2 Posts

Posted - 2007-05-03 : 02:29:30
Hi

I am trying schedule a job programatically that runs a stored proc with parameters.Output has to be saved to a csv file.
But there could be more than 1 jobs for o/nite processing
ie
exec my_proc 12 - result will be saved to 12.csv
exec my_proc 42 - result will be saved to 42.csv

Is this possible ?

thank you

AndrewMurphy
Master Smack Fu Yak Hacker

2916 Posts

Posted - 2007-05-03 : 05:43:14
very possible....all you need is for my_proc to accept an input variable and then process that variable into becoming part of the output file name.

have a look at this to get you started...

http://www.nigelrivett.net/SQLTsql/WriteTextFile.html
Go to Top of Page

nr
SQLTeam MVY

12543 Posts

Posted - 2007-05-03 : 06:41:06
How do you want to write the file?

Easiest for this is probably bcp using queryout.
You will execute the bcp command as a string using xp_cmdshell. Just create the output file name in that string using the parameter which you use to call the SP.


==========================================
Cursors are useful if you don't know sql.
DTS can be used in a similar way.
Beer is not cold and it isn't fizzy.
Go to Top of Page

ft
Starting Member

2 Posts

Posted - 2007-05-03 : 19:01:02
Either of them will do the job.
Thank you for your help.
Go to Top of Page
   

- Advertisement -