Product articles SQL Prompt SQL Code Snippets
Quick SQL Prompt tip – using the ii…

27 September 2016
27 September 2016

Quick SQL Prompt tip – using the ii snippet

SQL Prompt includes a number of snippets by default that can help you quickly write T-SQL code. These are templates of code that users use regularly. One of the more popular snippets is the “ii” snippet that helps with inserting data into a table.

If I type “ii” and hit tab, I quickly get the INSERT INTO code added to my query batch. You can see the snippet after typing “ii” below.


Typically, I don’t see this because I can type “ii” and hit TAB very quickly. While this doesn’t take much more time than typing “ins” and then TAB, the simple “ii” just feels like I’m coding more efficiently. Once I do this, it results in a template of the code and a list of tables:


To select a table, I can click one or scroll down with the mouse, but I tend to use the keyboard. If I start typing the first letter of a table, for example, “a”, I get the list quickly limited to just those tables:


Now if I type TAB to select the “Address” table, I will get the full insert statement, with my cursor in the first column value. In the image below, my blinking cursor is actually between the quotes for the AddressLine1 column:


Now I can enter the data values I need, and easily insert those into a table. If I need multiple rows, I’ll copy and paste the section after VALUES and I separate each set of parentheses with a comma.

There are a number of built-in snippets for SQL Prompt, and many of them are very simple, but they can greatly speed up your T-SQL coding if you learn what they are. I’d suggest you download our SQL Prompt Quick Reference Guide and practice using a few of these shortcuts in your code.

I also cover a few other snippets including CDB (CREATE DATABASE) and SSF (SELECT * FROM) in the new series of #SuperSQLTips videos. Take a look and you’ll find handy tricks from other Data Platform MVPs and SQL Server experts too:

If you’re not a SQL Prompt user, download a free trial and see how much more productive you can be writing code every day.

Like this? Share it with other SQL professionals using the social sharing buttons below. Simply tweet: I’ve just read @way0utwest’s blog on using the ii snippet with #SQLPrompt – see the #SuperSQLTip at center>

Tools in this post

SQL Prompt

Write, format, and refactor SQL effortlessly

Find out more

You may also like

  • Article

    SQL Prompt Code Analysis: A Hint is Used (PE004-7)

    Phil Factor suggests a philosophy of "the SQL query optimizer knows best" when it comes to choosing the right execution plan. Use hints as a last resort, and evaluate them carefully whenever SQL Prompt warns you of their presence in your SQL code.

  • Article

    SQL Prompt Safety Net Features for Developers

    Ever accidentally executed code while connected to the right database but the wrong server? Phil Factor describes a few common mishaps that everyone working in SSMS will have experienced, and how SQL Prompt "Tab Magic" provides insurance against their consequences.

  • Article

    SQL Prompt 10: What's New?

    Tony Davis reviews the major new features of SQL Prompt 10, included improved 'ranking' of its code auto-completion suggestions, tab history improvements to make it easier to find 'lost' code, and auto-fixing of code that breaks code analysis rules.

  • Article

    Beyond Formatting: Improving SQL Code using SQL Prompt Actions

    Louis Davidson explains how he uses the SQL Prompt refactoring 'Actions' to qualify object names, standardize the use of aliases, and make other instant changes that improve the overall quality of his SQL code.

  • Forums

    SQL Prompt Forum

    Write, format, and refactor SQL effortlessly