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.
| Author |
Topic |
|
pmccann1
Posting Yak Master
107 Posts |
Posted - 2008-01-09 : 07:33:59
|
| Is there away from with in sql to creat a job that will run a stored procedure that creates a csv file from a database table and names it with the date you run it? |
|
|
RickD
Slow But Sure Yak Herding Master
3608 Posts |
Posted - 2008-01-09 : 10:03:43
|
| Yes, use BCP to do this. |
 |
|
|
pmccann1
Posting Yak Master
107 Posts |
Posted - 2008-01-09 : 11:16:01
|
| That is the line i have been going down but i think i must have it wrong.bcp Reports.dbo.test out d:\work\tc.csv -c -Snicis_ql -Uadmin -Padm1this works it it is a .bat file and also if i type it into cmd prompt, but how do i get a job within sql to kick this off |
 |
|
|
jezemine
Master Smack Fu Yak Hacker
2886 Posts |
Posted - 2008-01-09 : 11:28:00
|
if you want an agent job to run this, just use a CmdExec step to run the .bat file elsasoft.org |
 |
|
|
pmccann1
Posting Yak Master
107 Posts |
Posted - 2008-01-09 : 11:34:22
|
| am i right in putting the path to were the .bat file is located in there. if so this is not working it is not kicking it off when i run the job |
 |
|
|
jezemine
Master Smack Fu Yak Hacker
2886 Posts |
Posted - 2008-01-09 : 11:38:29
|
you can either put the path to the .bat, or the just put the bcp command as the command text of the CmdExec step.Note that if you use the path to the .bat, the path must be local to the sql server where agent is running. elsasoft.org |
 |
|
|
stowellg
Starting Member
9 Posts |
Posted - 2008-01-09 : 13:14:35
|
| Suggestion for running this in SQL -Declare @CMD varchar(255)Declare @return intSet @CMD = 'bcp Reports.dbo.test out d:\work\tc.csv -c -Snicis_ql -Uadmin -Padm1'exec @return = master..xp_cmdshell @CMDI have a stupid question for you... |
 |
|
|
|
|
|