Script for SQL Server Agent jobs

The below script is useful in finding the important information about the jobs in your SQL Server like who is the owner of your job, if you have set any notification email or not if it set then to which Emailid the mail will be sent to, when it was created and when was the […]

SQL Agent Job for databases in availability group

When we have SQL Server job running for databases in Always-On there could be need of running a specific job on Primary database only. In such cases we are required to create the job on every server and add the logic that it runs only on the Primary server. The below template can be used […]

Database stuck in Single_user mode

Today I got a call from a colleague who was trying to restore a database, and as the generic first step had put the database in single_user mode and after that ran the Restore query which somehow failed. Now the issue began, this database which was put on single_user mode was not coming back to […]

Creating scripts for repetitive tasks

One of the most mundane task to do is providing permission to a user on multiple stored procedures in a database. There is not much you can do, either provide ddladmin permission onto the database (it provides much more permission than required) or manually provide permission to each SP using Grant Execute or using GUI. […]