Press "Enter" to skip to content

Snippets in SQL Server Management Studio

Pablo Lozano creates a snippet:

The work of a DBA sometimes involves very repetive tasks:

  • Create a new login / users, or add/remove permissions
  • Run manual index / stats operations when the scheduled maintenance tasks are not enough and need a manual “push”
  • Taking a backup or restore one to troubleshoot issues or restore missing data…

There are many ways to accomplish this:

You can keep a folder full of scripts and just open the one you need and run it

Use a third-party tool to store all those scripts and paste them with a quick shortcut or a few clicks

Or the one I’ll be discussing, using snippets

Read on to see how you can create these. Snippets were great as a DBA, but I think I liked them even more when I was doing database development work, especially for repetitive code blocks like try-catch (or try-catch around a transaction) or searching in sys.sql_modules for a specific bit of code.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.