Script to find SQL Job activity details

Written by VidhyaSagar. Posted in Scripts

Ive written a script to find the job activity details, this script will give the output similar to job activity monitor in SQL2K5 or SQL2K8. In my working place we had a request to collect the job details from all the servers which includes all version of SQL Server. Ive tried sp_help_jobactivity for SQL2K5 SQL2k8, however it doesnt provide the columns needed. So Ive written a script to get customized output, this script will also work with SQL2K. The script will fetch the following details

VN:F [1.9.17_1161]
Rating: 5.0/5 (1 vote cast)
VN:F [1.9.17_1161]
Rating: 0 (from 0 votes)

Script to get row count for all the tables in all the databases

Written by VidhyaSagar. Posted in Scripts

Ive written this script to get details of row count in all the tables in all the database including the system database. You can modify the script to exclude system database if you dont need details for that. You can see that I havent use COUNT() function to get these values, If I run using this function for all the db then it will take more time and resource.

VN:F [1.9.17_1161]
Rating: 0.0/5 (0 votes cast)
VN:F [1.9.17_1161]
Rating: 0 (from 0 votes)

Trigger to Check Job failures

Written by VidhyaSagar. Posted in Scripts

I was trying to find a alert which could fire immediately upon any of the job failure in the server to send an email. Unfortunately I couldn’t find any the alert related to this. So I thought of writing a DML trigger which should fire immediately when an entry is inserted in sysjobhistory table on msdb database. The next step is that the trigger should send a mail when there is failure in the job, hence Ive used run_status column in the table, as all the DBAs know when this column has a value 0 then it states the job has been failed. Ive tried this script in SQL Server greater than version 2000 however its not working on it. This script works only on SQL Server 2000, still some of them are still working on SQL 2000 so I thought this script has still value. This DML trigger will send an email upon any of the job failure.

VN:F [1.9.17_1161]
Rating: 0.0/5 (0 votes cast)
VN:F [1.9.17_1161]
Rating: 0 (from 0 votes)

Recent Comments

Amit Bhatt

|

Hi Deepak,

Thanks for such a nice article.

You missed one thing to add in code:
@article = ‘all’,

Hence the script will be like this:
EXEC sp_addsubscription
@publication = ‘mypublication’,
@article = ‘ALL’,
@subscriber = ‘Subscriberservername’,
@destination_db = ‘mydestinationdbname’,
@reserved=’Internal’

Error 18486 | Platformblog

|

[...] SQL-Articles » Troubleshooting Login failed Error 18456This is one of the infamous error message (and number) that most of the DBAs …. 18486. Login failed for user ‘%.*ls’ because the account is currently locked out. [...]

VidhyaSagar

|

Naveen,
I’ll check this out and get back to you.

balakiran

|

Thanks man, Very simple & easy to understand !!!!