Showing posts with label window. Show all posts
Showing posts with label window. Show all posts

Wednesday, March 21, 2012

Job History report

Hello all,

I need to create a report on a certain Job on my server. It should look exactly like the "View History" window.

to do that, i need to find a way to group the logged steps by the job executions. The problem is that in the sysjobhistory table there's only a instance_id field that runs incrementally, with no way to identify the execution…

any ideas?

You'll need to join so sysjobs and sysoperators if you want the Job Name and Operators that were emailed, net sent or paged.

You might be able to group the run_date and run_time together and use this for your "key" to group the job steps together. Note: run_time is in a 24 hour format and is not left zero filled (i.e. 10001 is 1:00:01 am, 152531 is 15:25:31 pm).

convert(varchar(8), run_date) + right('000000' + convert(varchar(6), run_time), 6) -->> will give you the date and hhmmss the step executed (i.e. 20061225010001).

You could parse the results (maybe using hours and/or minutes) to group the steps together.

The above is a quick and dirty and depending upon how often and how long your jobs run, may not work.

Since the format of job history is consitent with step_id of 0 as the job completion step, you can write a stored procedure and use a cursor to group the steps (read all the steps and "break" each time a step_id of 0 is encountered).

|||

Thanks,

The first way you wrote will not work since you cannot group on Running Date & Time - this group will not identify all the steps in a certain run in the same group.

I also thought of the second way, but it seemed too costly.

How does the "view job history" window know how to separate the job executions?

|||

Liran, that is why I wrote that the first step "may not work". If your job ran once each hour, started at 1 minute past the hour and ran for less than 59 minutes every time, the first method would work since each step would have the same date and hour time stamp. Obviously this won't work if your job starts at 59 minutes after the hour and runs for more than one minute or runs for more than one hour.

Not sure how the "view job history" works but would imagine it does a similar activity as what I described for writing a stored procedure. Since you can't have the same job name executing at the same time on the same server, the starting date/time of the job and each of it's steps will be in chronological order; doesn't matter if the job runs more than one our or spans over multiple days.

Another option might be to add the duration (from step_id = 0) to the start date/time to get the ending date/time of the job (NOT the steps). You could then choose any of the rows in sysjobhistory that fall between the start date/time and the calculated ending date/time of the job.

You said you had an idea, why don't you describe it and we might be able to expand upon it...

|||

OK, Now I understood what you meant, but this method is not relevant to me since this job runs for more then 1 hour with 1 min between each run…

About the second Idea, I meant I also thought of the second idea you wrote (with the procedure and cursor) but it seems to me too costly to be executed every time the report is viewed…

Thanks, I just thought there's somewhere a "job running instance id" that I'm overlooking…

|||

Pls chek the following post..It may help you

http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=1033004&SiteID=1

Monday, March 19, 2012

Job History

Hello all,
Is there a way to define how much history will be logged in the Job History
window?
I need to save history from the whole last week's run, but it keeps been
deleted.
ThanksLiran
Take a look at sysjobhistory system table
"Liran" <Liran@.discussions.microsoft.com> wrote in message
news:C03C14C4-43ED-4E97-BE97-E71FD083F331@.microsoft.com...
> Hello all,
> Is there a way to define how much history will be logged in the Job
> History
> window?
> I need to save history from the whole last week's run, but it keeps been
> deleted.
> Thanks|||Actually, I did, but the solution is to change the dafault log size in the
SQL Server Agent Property window.
"Uri Dimant" wrote:
> Liran
> Take a look at sysjobhistory system table
> "Liran" <Liran@.discussions.microsoft.com> wrote in message
> news:C03C14C4-43ED-4E97-BE97-E71FD083F331@.microsoft.com...
> > Hello all,
> >
> > Is there a way to define how much history will be logged in the Job
> > History
> > window?
> > I need to save history from the whole last week's run, but it keeps been
> > deleted.
> >
> > Thanks
>
>|||Liran
To modify the maximum number of records maintained in sysjobhistory open
Enterprise Manager and expand the Server to modify. Expand Managment and
Right Click SQL Server Agent and select Properties.
Under the Job System tab there is two text boxes. Maximum job history log
size (rows) and Maximum job hisory rows per job.
-rows per job is the maximum number of rows in sysjobhistory for a
partilcuar job
-log size (rows) is the maximum number rows in sysjobhistory for all jobs
Updating these values will modify how many rows are maintained.
-Peter Ward
WARDY IT Solutions
"Liran" wrote:
> Actually, I did, but the solution is to change the dafault log size in the
> SQL Server Agent Property window.
>
> "Uri Dimant" wrote:
> > Liran
> > Take a look at sysjobhistory system table
> >
> > "Liran" <Liran@.discussions.microsoft.com> wrote in message
> > news:C03C14C4-43ED-4E97-BE97-E71FD083F331@.microsoft.com...
> > > Hello all,
> > >
> > > Is there a way to define how much history will be logged in the Job
> > > History
> > > window?
> > > I need to save history from the whole last week's run, but it keeps been
> > > deleted.
> > >
> > > Thanks
> >
> >
> >

Monday, March 12, 2012

job fails when run with sqlagent.

I have a storeded procedure 'refresh_all' that denormalizes some tables for
easier reporting. I can run it fine from isqlw command window, but when I
put it into a job it consistently fails.
I'm probably over looking something really basic.
Here is the error from the single step
Executed as user: son\kevinrug. String or binary data would be truncated.
[SQLSTATE 22001] (Error 8152) The statement has been terminated. [SQLSTATE
01000] (Error 3621). The step failed.
At first I thought it was the user account, but I verified the it has
permissions in the database and on the procedure. Beside, I am system admin
and dbo so that shouldn't have been a problem.
Also, I am starting the service (sqlagent) under my network account.
Help greatly appreciated.
kevin
>> ... String or binary data would be truncated.
The error message suggests it has to do with the data in the tables
involved. Check your processes for datatype conversions, lengthy character
data inserted into tables with types of shorter length, mismatched sql
operations like joins on columns with incompatible types etc.
Anith
|||ok I'll look at that. I was wondering if this is what it meant, but since it
ran ok interactively I wasn't sure.
Also, will try running each sub-proc to see which is failing.
"Anith Sen" <anith@.bizdatasolutions.com> wrote in message
news:eoJP1GJEFHA.612@.TK2MSFTNGP15.phx.gbl...
> The error message suggests it has to do with the data in the tables
> involved. Check your processes for datatype conversions, lengthy character
> data inserted into tables with types of shorter length, mismatched sql
> operations like joins on columns with incompatible types etc.
> --
> Anith
>
|||Thanks again.
After investigating, I found I had turned ansi_warnings OFF, once I put this
in the procedure it runs great.
kevin
"Anith Sen" <anith@.bizdatasolutions.com> wrote in message
news:eoJP1GJEFHA.612@.TK2MSFTNGP15.phx.gbl...
> The error message suggests it has to do with the data in the tables
> involved. Check your processes for datatype conversions, lengthy character
> data inserted into tables with types of shorter length, mismatched sql
> operations like joins on columns with incompatible types etc.
> --
> Anith
>

job fails when run with sqlagent.

I have a storeded procedure 'refresh_all' that denormalizes some tables for
easier reporting. I can run it fine from isqlw command window, but when I
put it into a job it consistently fails.
I'm probably over looking something really basic.
Here is the error from the single step
Executed as user: son\kevinrug. String or binary data would be truncated.
[SQLSTATE 22001] (Error 8152) The statement has been terminated. [S
QLSTATE
01000] (Error 3621). The step failed.
At first I thought it was the user account, but I verified the it has
permissions in the database and on the procedure. Beside, I am system admin
and dbo so that shouldn't have been a problem.
Also, I am starting the service (sqlagent) under my network account.
Help greatly appreciated.
kevin>> ... String or binary data would be truncated.
The error message suggests it has to do with the data in the tables
involved. Check your processes for datatype conversions, lengthy character
data inserted into tables with types of shorter length, mismatched sql
operations like joins on columns with incompatible types etc.
Anith|||ok I'll look at that. I was wondering if this is what it meant, but since it
ran ok interactively I wasn't sure.
Also, will try running each sub-proc to see which is failing.
"Anith Sen" <anith@.bizdatasolutions.com> wrote in message
news:eoJP1GJEFHA.612@.TK2MSFTNGP15.phx.gbl...
> The error message suggests it has to do with the data in the tables
> involved. Check your processes for datatype conversions, lengthy character
> data inserted into tables with types of shorter length, mismatched sql
> operations like joins on columns with incompatible types etc.
> --
> Anith
>|||Thanks again.
After investigating, I found I had turned ansi_warnings OFF, once I put this
in the procedure it runs great.
kevin
"Anith Sen" <anith@.bizdatasolutions.com> wrote in message
news:eoJP1GJEFHA.612@.TK2MSFTNGP15.phx.gbl...
> The error message suggests it has to do with the data in the tables
> involved. Check your processes for datatype conversions, lengthy character
> data inserted into tables with types of shorter length, mismatched sql
> operations like joins on columns with incompatible types etc.
> --
> Anith
>

job fails when run with sqlagent.

I have a storeded procedure 'refresh_all' that denormalizes some tables for
easier reporting. I can run it fine from isqlw command window, but when I
put it into a job it consistently fails.
I'm probably over looking something really basic.
Here is the error from the single step
Executed as user: son\kevinrug. String or binary data would be truncated.
[SQLSTATE 22001] (Error 8152) The statement has been terminated. [SQLSTATE
01000] (Error 3621). The step failed.
At first I thought it was the user account, but I verified the it has
permissions in the database and on the procedure. Beside, I am system admin
and dbo so that shouldn't have been a problem.
Also, I am starting the service (sqlagent) under my network account.
Help greatly appreciated.
kevin>> ... String or binary data would be truncated.
The error message suggests it has to do with the data in the tables
involved. Check your processes for datatype conversions, lengthy character
data inserted into tables with types of shorter length, mismatched sql
operations like joins on columns with incompatible types etc.
--
Anith|||ok I'll look at that. I was wondering if this is what it meant, but since it
ran ok interactively I wasn't sure.
Also, will try running each sub-proc to see which is failing.
"Anith Sen" <anith@.bizdatasolutions.com> wrote in message
news:eoJP1GJEFHA.612@.TK2MSFTNGP15.phx.gbl...
> >> ... String or binary data would be truncated.
> The error message suggests it has to do with the data in the tables
> involved. Check your processes for datatype conversions, lengthy character
> data inserted into tables with types of shorter length, mismatched sql
> operations like joins on columns with incompatible types etc.
> --
> Anith
>|||Thanks again.
After investigating, I found I had turned ansi_warnings OFF, once I put this
in the procedure it runs great.
kevin
"Anith Sen" <anith@.bizdatasolutions.com> wrote in message
news:eoJP1GJEFHA.612@.TK2MSFTNGP15.phx.gbl...
> >> ... String or binary data would be truncated.
> The error message suggests it has to do with the data in the tables
> involved. Check your processes for datatype conversions, lengthy character
> data inserted into tables with types of shorter length, mismatched sql
> operations like joins on columns with incompatible types etc.
> --
> Anith
>

Wednesday, March 7, 2012

Job Activity Monitor

Is there any way to modify the layout of the Job Activity Monitor?

After I resize columns and/or the size of the window, when I close the window it does not save.

I assume this is a "feature". Any plans on fixing this?

Thanks!!!

I agree, you open the Job activity monitor, size the screen exactly how you like it, widen the left pane so you can see the job names in full, pull up the splitter so you can see more of the history details and less of the job runs, and then you close the window and lose it all and have to start again. Very very annoying.|||

No, this is not possible. This would be a good suggestion to file on Microsoft Connect: http://connect.microsoft.com/SQLServer/Feedback/.

Paul A. Mestemaker II
Program Manager
Microsoft SQL Server Manageability
http://blogs.msdn.com/sqlrem/

Job Activity Monitor

Is there any way to modify the layout of the Job Activity Monitor?

After I resize columns and/or the size of the window, when I close the window it does not save.

I assume this is a "feature". Any plans on fixing this?

Thanks!!!

I agree, you open the Job activity monitor, size the screen exactly how you like it, widen the left pane so you can see the job names in full, pull up the splitter so you can see more of the history details and less of the job runs, and then you close the window and lose it all and have to start again. Very very annoying.|||

No, this is not possible. This would be a good suggestion to file on Microsoft Connect: http://connect.microsoft.com/SQLServer/Feedback/.

Paul A. Mestemaker II
Program Manager
Microsoft SQL Server Manageability
http://blogs.msdn.com/sqlrem/