Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase

Failed SQL job info from PS to sql table Expand / Collapse
Author
Message
Posted Wednesday, July 11, 2012 12:02 PM
Valued Member

Valued MemberValued MemberValued MemberValued MemberValued MemberValued MemberValued MemberValued Member

Group: General Forum Members
Last Login: Monday, August 11, 2014 3:08 PM
Points: 72, Visits: 199
Hi All,

Please have a look at the below link and help me to get the details (as 4 Columns) into a SQL Server table instead of Mail as I can make a SSR report from the data.
SERVER =
JOB =
LASTRUN =
LASTRUNDATE =

http://www.sqlservercentral.com/blogs/sqlsandwiches/2012/01/29/find-failed-sql-jobs-with-powershell/

Regards
Srikanth Reddy Kundur
Post #1328482
Posted Wednesday, July 11, 2012 12:16 PM


Valued Member

Valued MemberValued MemberValued MemberValued MemberValued MemberValued MemberValued MemberValued Member

Group: General Forum Members
Last Login: Friday, August 22, 2014 6:08 AM
Points: 60, Visits: 890
Have you tried to change the part where it says
$msg.body = $msg.body + "`n `n FAILED JOB INFO:... [snip]
to something like this
$sql = "insert YourTableName (server, job, last_run_status, last_run_date)
values ('$sqlserver', '$jobname', '$jobLastRunOutcome', '$jobLastRun');"

then run that into your SQL Server? Adjusted, of course, for your table structure.
If you have something that's failing send the code and error message and maybe someone here could help a little more.
Post #1328487
Posted Wednesday, July 25, 2012 6:09 PM
Valued Member

Valued MemberValued MemberValued MemberValued MemberValued MemberValued MemberValued MemberValued Member

Group: General Forum Members
Last Login: Monday, August 11, 2014 3:08 PM
Points: 72, Visits: 199
Changed the code as suggested, the job executes successful but no records are getting inserted, Can anyone help on the script please.

Regards
S.R.Kundur
Post #1335514
Posted Tuesday, January 8, 2013 11:39 PM


Ten Centuries

Ten CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen Centuries

Group: General Forum Members
Last Login: Wednesday, June 18, 2014 3:28 AM
Points: 1,044, Visits: 1,839
Paste your complete PS code here. Also, is there a specific reason not to use sysjobshistory and sysjobs tables for reporting needs?

Regards/Raunak
Now a member of Linkedin

Please visit the all new Performance Point Forum
Please visit the all new Data Mining and Business Analytics Forum
Post #1404557
« Prev Topic | Next Topic »

Add to briefcase

Permissions Expand / Collapse