Click here to monitor SSC
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


Stored Procedure (or) SQL Script Output to Text File


Stored Procedure (or) SQL Script Output to Text File

Author
Message
Anil Kumar Kurra
Anil Kumar Kurra
Forum Newbie
Forum Newbie (7 reputation)Forum Newbie (7 reputation)Forum Newbie (7 reputation)Forum Newbie (7 reputation)Forum Newbie (7 reputation)Forum Newbie (7 reputation)Forum Newbie (7 reputation)Forum Newbie (7 reputation)

Group: General Forum Members
Points: 7 Visits: 16
Hi All,

I am having a Stored Procedure Or SQL Script to be attached to Job Scheduler. When this Stored procedure executes it generates some output text. I need to store this output to text file when ever this store Procedure (or) SQL Script executed by job Scheduler.

Please help me how to handle this?

Thanks,
Anil
Greg Charles
Greg Charles
SSCarpal Tunnel
SSCarpal Tunnel (4.1K reputation)SSCarpal Tunnel (4.1K reputation)SSCarpal Tunnel (4.1K reputation)SSCarpal Tunnel (4.1K reputation)SSCarpal Tunnel (4.1K reputation)SSCarpal Tunnel (4.1K reputation)SSCarpal Tunnel (4.1K reputation)SSCarpal Tunnel (4.1K reputation)

Group: General Forum Members
Points: 4089 Visits: 5823
This article http://thiagsundar.wordpress.com/export-data-to-text-file/ discusses several options for this. Personally, I'd create an SSIS package that executes the stored procedure and has a flat file connection for the destination file. The package can be executed in a job step.

Greg
Anil Kumar Kurra
Anil Kumar Kurra
Forum Newbie
Forum Newbie (7 reputation)Forum Newbie (7 reputation)Forum Newbie (7 reputation)Forum Newbie (7 reputation)Forum Newbie (7 reputation)Forum Newbie (7 reputation)Forum Newbie (7 reputation)Forum Newbie (7 reputation)

Group: General Forum Members
Points: 7 Visits: 16
Hi Charles,

Thanks for the reply. My Stored Procedure contains the cursor. The output of the stored procedure contains all the Logins and their passwords and default database assigned. This all information when i execute on Query Analyser it will display output on the screen.

I need to execute this stored procedure from Job scheduler and store the output some where in text file.

Can you suggest me How you mention path of the file during execution of stored procedure?

Please help me.

Thanks,
Anil
WayneS
WayneS
SSCertifiable
SSCertifiable (6.2K reputation)SSCertifiable (6.2K reputation)SSCertifiable (6.2K reputation)SSCertifiable (6.2K reputation)SSCertifiable (6.2K reputation)SSCertifiable (6.2K reputation)SSCertifiable (6.2K reputation)SSCertifiable (6.2K reputation)

Group: General Forum Members
Points: 6234 Visits: 10401
Anil Kumar Kurra (4/29/2009)
Hi All,

I am having a Stored Procedure Or SQL Script to be attached to Job Scheduler. When this Stored procedure executes it generates some output text. I need to store this output to text file when ever this store Procedure (or) SQL Script executed by job Scheduler.

Please help me how to handle this?

Thanks,
Anil

I take it that you mean you have a scheduled job to be run by SQL Server Agent, as opposed to a Scheduled Task to be run by the operating system.

Open up the job, then open up the step. Go to the advanced tab. Click in the "Output File" and enter the location and filename for the output. Save all changes. When the job is run, it will now pump the output to this file.

Wayne
Microsoft Certified Master: SQL Server 2008
Author - SQL Server T-SQL Recipes
If you can't explain to another person how the code that you're copying from the internet works, then DON'T USE IT on a production system! After all, you will be the one supporting it!
Links: For better assistance in answering your questions, How to ask a question, Performance Problems, Common date/time routines,
CROSS-TABS and PIVOT tables Part 1 & Part 2, Using APPLY Part 1 & Part 2, Splitting Delimited Strings

Anil Kumar Kurra
Anil Kumar Kurra
Forum Newbie
Forum Newbie (7 reputation)Forum Newbie (7 reputation)Forum Newbie (7 reputation)Forum Newbie (7 reputation)Forum Newbie (7 reputation)Forum Newbie (7 reputation)Forum Newbie (7 reputation)Forum Newbie (7 reputation)

Group: General Forum Members
Points: 7 Visits: 16
Hi,

I had tried that method. But in that output file it is storing the Job executed Successfully.

It is not storing the output of the script.

It is storing Job has executed successfully in that file everytime the job executes.

Please let me know on this.

Regards,
Anil
WayneS
WayneS
SSCertifiable
SSCertifiable (6.2K reputation)SSCertifiable (6.2K reputation)SSCertifiable (6.2K reputation)SSCertifiable (6.2K reputation)SSCertifiable (6.2K reputation)SSCertifiable (6.2K reputation)SSCertifiable (6.2K reputation)SSCertifiable (6.2K reputation)

Group: General Forum Members
Points: 6234 Visits: 10401
Well, I don't know what to tell you. This is the method that I use, and the log files from the jobs do contain the output from the procedure. From both print statements, and select statements.

Wayne
Microsoft Certified Master: SQL Server 2008
Author - SQL Server T-SQL Recipes
If you can't explain to another person how the code that you're copying from the internet works, then DON'T USE IT on a production system! After all, you will be the one supporting it!
Links: For better assistance in answering your questions, How to ask a question, Performance Problems, Common date/time routines,
CROSS-TABS and PIVOT tables Part 1 & Part 2, Using APPLY Part 1 & Part 2, Splitting Delimited Strings

Greg Charles
Greg Charles
SSCarpal Tunnel
SSCarpal Tunnel (4.1K reputation)SSCarpal Tunnel (4.1K reputation)SSCarpal Tunnel (4.1K reputation)SSCarpal Tunnel (4.1K reputation)SSCarpal Tunnel (4.1K reputation)SSCarpal Tunnel (4.1K reputation)SSCarpal Tunnel (4.1K reputation)SSCarpal Tunnel (4.1K reputation)

Group: General Forum Members
Points: 4089 Visits: 5823
Anil Kumar Kurra (4/29/2009)
Hi Charles,

Thanks for the reply. My Stored Procedure contains the cursor. The output of the stored procedure contains all the Logins and their passwords and default database assigned. This all information when i execute on Query Analyser it will display output on the screen.

I need to execute this stored procedure from Job scheduler and store the output some where in text file.

Can you suggest me How you mention path of the file during execution of stored procedure?

Please help me.

Thanks,
Anil


I'm talking about executing the stored procedure inside an SSIS package. The output file is designated in the flat file connection manager.

Greg
Therese Hutcheson
Therese Hutcheson
SSC-Addicted
SSC-Addicted (471 reputation)SSC-Addicted (471 reputation)SSC-Addicted (471 reputation)SSC-Addicted (471 reputation)SSC-Addicted (471 reputation)SSC-Addicted (471 reputation)SSC-Addicted (471 reputation)SSC-Addicted (471 reputation)

Group: General Forum Members
Points: 471 Visits: 27
.
TurnerC
TurnerC
Grasshopper
Grasshopper (18 reputation)Grasshopper (18 reputation)Grasshopper (18 reputation)Grasshopper (18 reputation)Grasshopper (18 reputation)Grasshopper (18 reputation)Grasshopper (18 reputation)Grasshopper (18 reputation)

Group: General Forum Members
Points: 18 Visits: 158
Wayne,

I create a stored procedure and I am executing that stored procedure via job step on the Job Agent creating a text file to an output file location on the advanced tab of the jobstep.
However, when the job runs and creates the text file there is heading on top of the text file. (see below) do you know how to get rid of the heading so the first actual record.

Job Diet Orders' : Step 1, 'Run Stored Procedure OrderProcedure' : Began Executing 2010-08-11; 27 :11:28
---------- ---------- ------------------------- --------------- - ---------- -------------------------------------------------------------------------------- -------- -------- ---------- ---------- -------------------- -------------------- --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Thank you for your time.
brett-531408
brett-531408
Forum Newbie
Forum Newbie (1 reputation)Forum Newbie (1 reputation)Forum Newbie (1 reputation)Forum Newbie (1 reputation)Forum Newbie (1 reputation)Forum Newbie (1 reputation)Forum Newbie (1 reputation)Forum Newbie (1 reputation)

Group: General Forum Members
Points: 1 Visits: 30
.? BT
Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum

































































































































































SQLServerCentral


Search