
It will strip out the comments automatically and, once again, save you a few extra minutes – especially handy if you’re dealing with a large script. Highlight the code, and select Remove comments from the Actions List. It’s wasted time manually removing each comment, which is where SQL Prompt steps in. While this is useful during development, you may well want or need to remove them again before committing the code into source control. While writing INSERT INTO statements, if you press Tab after entering the table name, SQL Prompt will helpfully add comments to remind you of the data types and sizes you need to provide for each column: This example was also featured in the Tip #11 video above. This will remove any carriage returns, tabs, extra spaces and so on, and compact the script as much as possible, ready for you to paste back into Visual Studio. Make your changes, then once you’re done, highlight the code, hit Ctrl and select Unformat. Copy and paste the SQL, and hit Ctrl K, Y to format your code to your own style. SQL Prompt can make life a little easier. Perhaps you have some SQL as a string in your application code, and you want to copy it out of Visual Studio to optimize it more easily inside SQL Server Management Studio. This will comment out each line, and can be easily reversed by selecting Uncomment from the Actions List. To quickly comment out lines of code you want to omit while testing or troubleshooting a query, highlight the code, press Ctrl and select Comment. You can then access these from the Actions List. You can also create your own custom surround-with snippets utilising the $SELECTEDTEXT$ placeholder in the Snippet Manager. These snippets utilise the $SELECTEDTEXT$ placeholder, so highlight your block of code, hit Ctrl and type BE or TC followed by tab, and it will surround your code block with the necessary SQL. ‘Surround-with’ snippets allow you to enclose a group of SQL statements into a logical block of code, such as a BEGIN…END block, or a TRY…CATCH block.

You can see it in action in this short video:Ģ. No more coding in Excel or repetitive quote, comma, arrow. Say you’re copying a list of items to insert data into a table, you can save yourself time manually adding quotes and commas by selecting the block of text, hitting Ctrl to bring up the Actions List, and selecting Add quotes & commas. In this blog, I’m going to tell you about five functions on the list you might not have come across, which I guarantee will save you a few more minutes each day, every day. Simply highlight your block of code and hit Ctrl, or click on the button to open up the list.

This little button right here is called the Actions List and it contains over 20 functions and snippets you can use in just a few keystrokes. When writing SQL, you can use SQL Prompt to quickly jump to some really handy formatting and refactoring actions.
