none
How to format in SSMS?

    Question

  • How can I format a query in SSMS so it does not look like this:

    sELecT * fRoM CusTomERs

    Monday, March 06, 2006 2:44 AM

Answers

All replies

  • Currently SSMS doesn't have any tools to format queries except of query designer and Ctrl+Shift+U or Ctrl+Shift+L.
    Monday, March 06, 2006 8:06 AM
  • I use promptsql.com for intellisense, which allow me to pick table and column names from a drop down. It integrates with SSMS and QA. -- Tibor Karaszi, SQL Server MVP http://www.karaszi.com/sqlserver/default.asp http://www.solidqualitylearning.com/ Blog: http://solidqualitylearning.com/blogs/tibor/ wrote in message news:da5be6aa-131a-4585-92c5-5114765096f7@discussions.microsoft.com... > Currently SSMS doesn't have any tools to format queries except of query > designer and Ctrl+Shift+U or Ctrl+Shift+L. >
    Monday, March 06, 2006 8:19 AM
  • Somebdy wake me from this bad dream!

    Yes I have tried promptsql. It is slow and does not format keywords, but is the only intellisense addon that works with SSMS. A much better product is SqlAssist but only works in Visual Studio. VS on the other hand is horrible for working with dbs, so I started cutting and pasting queries into SSMS.

    Shame on Microsoft for all this marketting hoopla and they basically put out archaic software that is stuck in the 70s.

     

    Monday, March 06, 2006 1:16 PM
  • FWIW the latest release of PromptSQL will auto-uppercase keywords, and has new caching features which should make it faster.
    Thursday, March 23, 2006 12:27 PM
  • I think SQL Pretty Printer Add-On for SSMS is what you need, take a look here:
    http://www.dpriver.com/sqlpp/ssmsaddin.html
    Friday, July 31, 2009 3:42 AM
  • How can I format a query in SSMS so it does not look like this:

    sELecT * fRoM CusTomERs


    You can format sql free online at: http://www.sqlusa.com/sqlformat/

    The default format result for the query above:

    SELECT *
    FROM   customers

    On the right hand side there are option settings.

    Kalman Toth SQL SERVER 2012 & BI TRAINING
    New Book: Beginner Database Design & SQL Programming Using Microsoft SQL Server 2012

    Sunday, August 02, 2009 3:46 PM
  • Check the following FREE formatter from ApexSQL. It has SSMS add-in too:

    http://www.apexsql.com/sql_tools_refactor.asp

    Here is a demo video:
    http://www.apexsql.com/Video/Flash/ApexSQL%20Refactor/ApexSQL%20Refactor.htm

    Hope it helps.








    Varsham Papikian, New England SQL Server User Group Executive Board, USA: www.nesql.org; http://www.linkedin.com/in/varshampapikian
    Sunday, August 02, 2009 8:50 PM
  • Easy,

    1. Open New Query in SQL SMS
    2. Copy and paste sql code into the window
    3. Highlight and right click code pasted and choose Design Query in Editor option
    4. It will format query in decent way and it works for all query sizes

    Enjoy,
    Max

    • Edited by Maximus Decimus Thursday, September 17, 2009 4:01 PM misspell word
    Thursday, September 17, 2009 3:57 PM
  • Thanks, it works for only some statements like SELECT, UPDATE, DELETE, INSERT; however, not for other where queries have IF, BEGIN, END, CURSOR, Variables, EXECUTE, etc.
    Jwalant Natvarlal Soneji, BE IT, Canada
    Thursday, June 23, 2011 7:50 PM
  • There is SQLPrompt in RedGate. I liked it while I had the trial version. 
    For every expert, there is an equal and opposite expert. - Becker's Law


    My blog
    Thursday, June 23, 2011 8:14 PM
  • This looks good, but how can I download just this tool for free as SSMS Add-on?
    For every expert, there is an equal and opposite expert. - Becker's Law


    My blog
    Thursday, June 23, 2011 8:20 PM
  • Hi Carl,

    Check out SSMS Tools Pack from http://www.ssmstoolspack.com, this is free and works fine with SQL Server 2005 / 2008 / 2008 R2/ Denali

    Apart from "Format Text" option, it has lot of good options


    Arunraj Chandrasekaran, MCTS, Author: SQLXpertise.com
    If you found this post useful, Please "Mark as Answer" or "Vote as Helpful"
    Friday, June 24, 2011 7:49 PM
  • It only puts keywords in upper case, but it doesn't really format.
    For every expert, there is an equal and opposite expert. - Becker's Law


    My blog
    Friday, June 24, 2011 8:01 PM
  • Yes, I agree, its not as good as SQL Prompt from Red Gate, which is the one i currently use. 
    Arunraj Chandrasekaran, MCTS, Author: SQLXpertise.com
    If you found this post useful, Please "Mark as Answer" or "Vote as Helpful"
    Saturday, June 25, 2011 5:11 PM
  • Hi, you can also use SSMSBoost add-in - it has Format SQL feature, along with many others ("go to definiion" for SQL Objects, Connection management and some more).
    Add-in is available as free edition as well

    SSMSBoost - ssms add-in adds quick source code navigation to SSMS, quick connection management & switching, shortcuts, auto replacements and object search. www.ssmsboost.com

    Tuesday, May 08, 2012 8:48 AM