473,883 Members | 1,750 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

sql server job output file -passing it onto second step

How do we pass on the step1 output file to step2 of the same job? I
would like to know the current job's output file programmeticall y,
instead of hard coding it. Any idaes would be appreciated.

Thanks

Jul 23 '05 #1
10 8185
It would be helpfull if you can explain what you are doing in each
step. If these steps are calling a stored proc/dts ect... do you know
the output file name ? If so, its easy to pass them as input parameters
to that job. Need more info on what you are trying to acomplish
here....

Jul 23 '05 #2
tram (tr****@hotmail .com) writes:
How do we pass on the step1 output file to step2 of the same job? I
would like to know the current job's output file programmeticall y,
instead of hard coding it. Any idaes would be appreciated.


It appears to be in msdb.dbo.sysjob steps.output_fi le. You could also
call sp_help_jobstep and get the data from there.
--
Erland Sommarskog, SQL Server MVP, es****@sommarsk og.se

Books Online for SQL Server SP3 at
http://www.microsoft.com/sql/techinf...2000/books.asp
Jul 23 '05 #3
I don't completely understand your question. Here's what I think you
mean: Job1 runs a script (or single query) that generates command
statements. Job2 runs the output from Job1.

One way to do this is use use the command line switches of the isql.exe
(query analyzer). Search for ISQL in books online to see a complete
list of the switches.

use -o to specify an output file.
use -i to specify an input.

Job1's output file would be Job2s input file.

Another way to generate sql, then run it, is to use the sp_executesql
stored procedure. The coding for this can get rather ugly and complex,
if you have to setup cursors. Sometimes isql command line is a simple
quick and dirty solution.

Hope this is what you were for.

Dave

tram wrote:
How do we pass on the step1 output file to step2 of the same job? I
would like to know the current job's output file programmeticall y,
instead of hard coding it. Any idaes would be appreciated.

Thanks


Jul 23 '05 #4
Thanks for responses. In the first step, I am doing tsql backup
maintenance command. If it fails, in the second step, I am using mail
procedure to send mail to DBAs. My intention is to attach the first
step's output file in the mail so that DBAs could review the log
without logging on to server.

1) I don't want to hard code the file name as it varies from jobn to
job.
2) I need to extract the output file name from one of the jobs tables
for which I need to give the jobID. How to find out the job ID for the
current step?
tr*******@hotma il.com wrote:
I don't completely understand your question. Here's what I think you
mean: Job1 runs a script (or single query) that generates command
statements. Job2 runs the output from Job1.

One way to do this is use use the command line switches of the isql.exe (query analyzer). Search for ISQL in books online to see a complete
list of the switches.

use -o to specify an output file.
use -i to specify an input.

Job1's output file would be Job2s input file.

Another way to generate sql, then run it, is to use the sp_executesql
stored procedure. The coding for this can get rather ugly and complex, if you have to setup cursors. Sometimes isql command line is a simple quick and dirty solution.

Hope this is what you were for.

Dave

tram wrote:
How do we pass on the step1 output file to step2 of the same job? I
would like to know the current job's output file programmeticall y,
instead of hard coding it. Any idaes would be appreciated.

Thanks


Jul 23 '05 #5
Thanks for responses. In the first step, I am doing tsql backup
maintenance command. If it fails, in the second step, I am using mail
procedure to send mail to DBAs. My intention is to attach the first
step's output file in the mail so that DBAs could review the log
without logging on to server.

1) I don't want to hard code the file name as it varies from jobn to
job.
2) I need to extract the output file name from one of the jobs tables
for which I need to give the jobID. How to find out the job ID for the
current step?
tr*******@hotma il.com wrote:
I don't completely understand your question. Here's what I think you
mean: Job1 runs a script (or single query) that generates command
statements. Job2 runs the output from Job1.

One way to do this is use use the command line switches of the isql.exe (query analyzer). Search for ISQL in books online to see a complete
list of the switches.

use -o to specify an output file.
use -i to specify an input.

Job1's output file would be Job2s input file.

Another way to generate sql, then run it, is to use the sp_executesql
stored procedure. The coding for this can get rather ugly and complex, if you have to setup cursors. Sometimes isql command line is a simple quick and dirty solution.

Hope this is what you were for.

Dave

tram wrote:
How do we pass on the step1 output file to step2 of the same job? I
would like to know the current job's output file programmeticall y,
instead of hard coding it. Any idaes would be appreciated.

Thanks


Jul 23 '05 #6
tram (tr****@hotmail .com) writes:
Thanks for responses. In the first step, I am doing tsql backup
maintenance command. If it fails, in the second step, I am using mail
procedure to send mail to DBAs. My intention is to attach the first
step's output file in the mail so that DBAs could review the log
without logging on to server.

1) I don't want to hard code the file name as it varies from jobn to
job.
2) I need to extract the output file name from one of the jobs tables
for which I need to give the jobID. How to find out the job ID for the
current step?


Not being a specialist on SQL Server Agent, I looked a little in Books
Online. I found this:

Job steps must be atomic. A job cannot pass Boolean values, data, or
numeric values between job steps. You can pass values from one
Transact-SQL job step to another by using permanent tables or global
temporary tables. You can pass values from one CmdExec job step to
another by using files.

A better approach could be two do all in one step. Now, this may be
problematic with a T-SQL step, since if backup fails, this could be
an error that aborts the batch.

But you could also implement the job as a CmdExec or an ActiveX script.
A CmdExec one is probably the simplest. First it runs the backup command
as

OSQL -n -E -b -u -o logfile.txt -Q "BACKUP ..."

Next you test %ERRORLEVEL% for a non-zero value. If there is a non-zero
value mail the file.

Note here that logfile.txt can be a scratch file. If you also want it
appended to the logfile for the job, just inluce a TYPE of the file in
the job.

--
Erland Sommarskog, SQL Server MVP, es****@sommarsk og.se

Books Online for SQL Server SP3 at
http://www.microsoft.com/sql/techinf...2000/books.asp
Jul 23 '05 #7
Erlnad,

Thanks for your constructive reply. I am using db maintenance plan and
in sql sglagent job window I am storing the output in file. In case of
step 1 fails, my aim is to extract the output file name of step 1 and
passit as an attachment to second step.

Jul 23 '05 #8
tram (tr****@hotmail .com) writes:
Thanks for your constructive reply. I am using db maintenance plan and
in sql sglagent job window I am storing the output in file. In case of
step 1 fails, my aim is to extract the output file name of step 1 and
passit as an attachment to second step.


Yeah, I know that by know, but I think you need to give up that path. I
can't think of a way how a T-SQL batch could find which job it's in -
after all the same batch could be running from somewhere else.

Possibly if you run an ActiveX task and use the SQLAgent object, this
information is available.

My idea was to keep it simple.

But you will have to step out of the realms of the maintenance job and
roll your own. Which should not be a big deal.
--
Erland Sommarskog, SQL Server MVP, es****@sommarsk og.se

Books Online for SQL Server SP3 at
http://www.microsoft.com/sql/techinf...2000/books.asp
Jul 23 '05 #9
How about this:

Specifiy the output file on the advanced tab of step1. (This way the
filename doesn't change.) Use a third step to make date copy of the
file.

Now you can hard code your failure step (step 2).

Make a step 3 that always fires. Here's sample Dos command line code
to do this.
Rem -----------------------------
Rem -- Parse date and time into xdate and xtime variables
for /F "tokens=2-4 delims=/ " %%a in ('echo %date%') do (set
xdate=%%c%%b%%a )
for /F "tokens=1-2 delims=:,." %%a in ('echo %time%') do (set
xtime=%%a%%b)

set outfile=c:\back up.log
set newfile=backup% xdate%%xtime%.l og

rem -- rename the file
ren %outfile% %newfile%
Rem -----------------------------

Dave

tram wrote:
Erlnad,

Thanks for your constructive reply. I am using db maintenance plan and in sql sglagent job window I am storing the output in file. In case of step 1 fails, my aim is to extract the output file name of step 1 and
passit as an attachment to second step.


Jul 23 '05 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
24161
by: Bill | last post by:
I used to be able to run the following ASP code on our corp machine (W2K Server Edition and IIS-5) and successfully send a net-msg to anyone on our intranet. Last week it stopped working... and I'm not sure what changed. (I had applied ALL the W2K update patches... but... I'm not sure if the problem started before or after that.) Did any recent W2K patches change the way createObject, wScript.shell, or "NET SEND" works?
4
1985
by: Phil Grimpo | last post by:
I had previously explained this problem in a different thread, but now that I have an IISState log, I figured I'd re-start the thred. My situation and the log are following... I have a very odd situation here. I have an administration page, where based on a users permissions, a recordset is called from the SQL server which has a list of paths to "Module Menus". Each of these menus are then placed into the page by calling...
5
3619
by: KathyB | last post by:
If someone could just explain this to me...I just don't get it! I have an aspx page where I retrieve several session variables and use xmlDocument to transform xml file with xsl file into an instruction document (not data based) - same as using an xml web control. The resulting html is on the client? but what about the server side of things? Trying to figure out how to change and save the xmlDocument. It I put a button OUTSIDE of the...
9
3034
by: Ivan Demkovitch | last post by:
Hi! I would like to know if I can save File on Server using server-side code? For example, I like to create thumbnail images and populate specific directory. Do I need specific permissions to do this? (I use public host) Thanks!
2
2166
by: Will Rickards | last post by:
In my web application there is an interactive report. Then there need to be a printable version a pdf. So I found this java tool csstoxslfo and the java fop tool from apache that will take my xhtml and css and convert it to pdf. Problem 1) I designed the aspx page to produce the xhtml as output. So how do I save that rendered page to a file on the server? I think it involves overriding the Render method. I wrote some code which...
4
1797
by: DKode | last post by:
I have developed a custom server control that displays a login page that authenticates against AD. The server control works fine, but now I am trying to figure out the best way to output custom html. The HTML output for the server control changes for each application I include the server control in. At first I thought about making an html file and just including it, but this won't work because with the custom html I output two textboxes...
5
2249
by: Grigs | last post by:
Hello, I have a project that contains a WebService that works great when connecting to it on my Localhost. Once we post the files to the test web server, all of the pages that do not touch the webservice work fine. However, the ones that do touch it get the following error: The request failed with HTTP status 404: Not Found Here is the full error:
17
2927
by: Michael | last post by:
Hello, I am writing an app that will sit on the desktop. It needs to be able to make a copy of a folder that sits on the server. It will copy the folder from the server and place it in the same directory on the same server. This is the line of code that I am using: System.IO.File.Copy(sDistinationFolder + "NewOrderTemplate", sDistinationFolder + myDate.Date + "_" + mtxtJobNumber.Text); So, as you can see, I am copying a folder...
1
2561
by: wavespirit75 | last post by:
Hi, I wrote a program which will use ffmpeg to convert media files. Media files can be converted with this string array being passed in to Runtime.getRunTime().exec: String cmd = {ffmpeg path, "-i", input file, output file}; However with the above method I couldn't set any options like "-s 176x144" for the output file's resolution, meaning if I use the following string array: String cmd ={ffmpeg path, "-i", input, "-s 176x144", output};...
7
16963
by: mukeshrasm | last post by:
Hi I am no able to send mail and it is giving this error Warning: mail(): SMTP server response: 530 5.7.3 Client was not authenticated in c:\inetpub\wwwroot\eshop\includes\classes\email.php on line 522 and the code is: <?php /* $Id: email.php,v 1.12 2003/06/17 17:29:44 dgw_ Exp $
0
9944
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
11154
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
10863
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10422
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9586
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7977
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
7136
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
1
4622
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
3241
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.