SQL SERVER – Upper Case Shortcut SQL Server Management Studio

Few days ago, I received code which is very similar to code shown below.
select *
from Sales.SalesOrderDetail
where ProductID > 777

I am not the guy who go crazy for formatting but I do appreciate proper coding. I like if the code was formatted like below.

SELECT *
FROM Sales.SalesOrderDetail
WHERE ProductID > 777

The fastest way one can do this in SSMS is either search and replace or using SSMS short cut to covert keywords to upper case.

What I do is I select the word and hit CTRL+SHIFT+U and it SSMS immediately changes the case of the selected word. Similar way if one want to convert cases to lower case, another short cut CTRL+SHIFT+L is also available.

Reference: Pinal Dave (http://blog.SQLAuthority.com)

About these ads

29 thoughts on “SQL SERVER – Upper Case Shortcut SQL Server Management Studio

  1. Hi Pinal,

    I tried the way and thanks for the shortcut, and CTRL+SHIFT+U is working fine but CTRL+SHIFT+L is not working for me to change the cases to lower case, it simply removes the whole line in query analyzer,

    I am having SQL SERVER 2008 in MS 2003 server.

    Thanks
    Manish

    Like

  2. Sir u are simply great….Thank u so much for this shortcut….
    One thing i wanna ask u… i ve used the Redgate toolbelt for using intellisense in sql server 2005….There is an option for formatting the code automatically….is there some similar in built option in sql server 2008

    Like

  3. A much easier and faster way is to use the SSMS Tools Pack, it includes a query text formatting procedure that you can configure (shortcut CTRL+SHIFT+F) and it can format in uppercase (or lowercase) all keywords of your query in one pass.

    http://www.ssmstoolspack.com/

    This tools pack come with a lot of other features but I only use it for the text formatting shortcut and I wouldn’t live without it.

    Like

  4. What SSMS should have is ability to uppercase only the keywords. This should not be hard for an IDE and I hope we get it in the next version. In the meantime SSMS Tools rocks.

    Like

  5. I respectfully ask why it is necessary to use upper case for keywords when keywords automatically appear in blue.

    I understand that many developers use upper case for keywords but I also know many developers who use lower case.

    Is this issue not simply a matter of personal style?

    Best wishes,

    Keith.

    Like

  6. There’s one cool feature if u have quickly change the case of block of text in multiple line.
    Simply hold down “Alt” key and make a rectangular selection. Now the you quickly modify the case for the text selected in the block.

    Like

  7. First time user can go with SSMS Menu and look there, shortcuts are mentioned for every menu command. Try to remeber that and keep a pratice using them.

    You will find lots of shorcut in SSMS menus.

    Like

  8. Pingback: SQLAuthority News – A Monthly Round Up of SQLAuthority Blog Posts Journey to SQL Authority with Pinal Dave

    • Hello Friends,
      Does any Know KeyBoard Shortcut to get Dependencies of a selected Table in Query Analyser Window.

      Alt – F1 Shows only Constraints, index , keys so.. on.

      But i need to view available Procedures and triggers Related that Table.

      This Option is available in Object Explorer Window on Right Click and Select ‘View Dependencies’. But this method consumes lot of time in finding out a specific table in object Explorer table List Tree.

      Like

  9. in response to Keith’s post – the reason that upper casing is used is that .SQL files can be saved and edited in a text editor such as notepad – this won’t pick up the formatting and automatically hightlight keywords in blue – if they’re in upper case thay stand out.

    Like

  10. I like mine the other way around. And when is sql going to start allowing the from statement to be placed first? I think ansi sql needs to incorporate this because it would really make intellisence a lot easier.

    Like

    • I start with a generic statement:
      SELECT *
      FROM table t

      After that, I just go back and write column names with the table alias (otherwise it is a huge list of columns to choose from):

      SELECT t.col1, t.col2
      FROM table t

      Like

  11. Thank you for the shortcuts. I went the other way around, going crazy with all the caps that I had to convert it all to lower case and make it indent. Anyway, thanks for the CTRL-SHIFT-L, that works great.

    Like

  12. Pingback: SQL SERVER – Weekly Series – Memory Lane – #037 | Journey to SQL Authority with Pinal Dave

  13. Hi,
    You are not just concentrating on queries but also concentrates on small things like this. Continue your great work. You have saved my time

    Like

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s