Compact Fomatting

pbukowskipbukowski Posts: 4 Bronze 1
edited September 1, 2016 8:21AM in SQL Prompt
Hello,

In SQL Prompt, I was wondering if you might be so kind as to consider providing some custom formatting like below :) I quite often have SQL sent to me butchered up and it's such a pain to re-format it. I like the very condensed/compact format like in the example way below. Notice nothing is aligned, it's simply tight and compact, with a single tab for nested statements.

Thoughts?
Thanks,
Paul
/*Start with a terribly formatted piece of SQL like this*/
   SELECT TOP 200 
   A.Col1
   ,A.Col2
   ,A.Col3
   ,A.Col4
   ,A.Col5
   ,A.Col6,
A.Col7,
A.Col8
,A.Col9
	FROM FSS.dbo.Table_1 A
WHERE 
EXISTS (	SELECT 1
	FROM 
	FSS.dbo.Table_2 B 
	WHERE 
	A.Col9 = B.Col3 AND 
		A.Col6 = B.Col6
)
ORDER BY A.Col1,
A.Col2


/*Click Format Something and have the SQL look exactly like this. Maybe call it "Clean & Compact Formatting":*/
SELECT TOP 200 A.Col1,A.Col2,A.Col3,A.Col4,A.Col5,A.Col6,
A.Col7,A.Col8,A.Col9
FROM FSS.dbo.Table_1 A
WHERE exists (
	SELECT 1
	FROM FSS.dbo.Table_2 B 
	WHERE A.Col9 = B.Col3 AND A.Col6 = B.Col6
)
ORDER BY A.Col1,A.Col2

Comments

  • Hi

    We’ve recently released a SQL Prompt beta with a more powerful formatting system which will enable you to format SQL in your suggested style. You can download it from here.

    If you have any trouble configuring your suggested style, please let me know.

    Thanks
    Ali
  • Awesome - I just downloaded and tried it out. I was able to automatically format the mess above to this:
    SELECT TOP 200 A.Col1, A.Col2, A.Col3, A.Col4, A.Col5, A.Col6, A.Col7,
    A.Col8, A.Col9
    FROM FSS.dbo.Table_1 A
    WHERE EXISTS (
    	SELECT 1
    	FROM FSS.dbo.Table_2 B
    	WHERE A.Col9 = B.Col3 AND A.Col6 = B.Col6
    )
    ORDER BY A.Col1, A.Col2
    

    It worked mint after I configured the style - great job. 8)

    Thank you !!!
    Paul
  • Excellent, glad to hear it's working for you :)
Sign In or Register to comment.