November 10, 2016 at 10:14 am
Can someone recommend a (free?) tool to format TSQL Code.
Ideally, it should be something working in both SSMS and Visual Studio (SSDT) as we use both for our TSQL Code.
This would help us with coding standards, debugging, etc.
Thanks
November 10, 2016 at 10:43 am
I've tried Poor Man's T-SQL Formatter[/url] and ApexSQL Refactor which gave me good results to organize messy code, but won't do everything I wanted.
They're good, but you should try them to see if they fit your needs.
November 11, 2016 at 2:34 am
I've used ApexSQL Refactor too
It's pretty good although I don't like some of the formatting produced
That said, it's free and should get you coding in a consistent manner
- Damian
November 11, 2016 at 5:27 am
Thanks 🙂
November 11, 2016 at 12:57 pm
Eric Mamet (11/10/2016)
Can someone recommend a (free?) tool to format TSQL Code.Ideally, it should be something working in both SSMS and Visual Studio (SSDT) as we use both for our TSQL Code.
This would help us with coding standards, debugging, etc.
Thanks
A bit ironic, I think. If you have coding standards, why aren't people following them?
--Jeff Moden
Change is inevitable... Change for the better is not.
November 11, 2016 at 1:54 pm
Jeff Moden (11/11/2016)
Eric Mamet (11/10/2016)
Can someone recommend a (free?) tool to format TSQL Code.Ideally, it should be something working in both SSMS and Visual Studio (SSDT) as we use both for our TSQL Code.
This would help us with coding standards, debugging, etc.
Thanks
A bit ironic, I think. If you have coding standards, why aren't people following them?
Can you tell the difference between artisanal hand-coded SQL that someone slaved over for an hour just to get all the keywords capitalized and the tabs lined up, versus SQL auto-formatted by a tool configured to match your coding standards? 🙂
"Do not seek to follow in the footsteps of the wise. Instead, seek what they sought." - Matsuo Basho
November 11, 2016 at 2:52 pm
Very good question!
The honest answer is a mixture of the followings
1) our coding standards is a document of too many pages (IMHO) so it becomes difficult to follow (I wrote most of it but under certain directives...)
2) I don't think it goes into much details about formatting
3) poor discipline
I can't really do much about 1 and 3 above and solving 2 would make 1 even worse...
But I reckon we can improve quite a bit by adopting a tool for formatting
I am also thinking of using SSMS templates.
Cheers
Eric
November 11, 2016 at 3:23 pm
Also, you can google "online t-sql formatter" and try out the features of various implementations with downloading and installing anything.
"Do not seek to follow in the footsteps of the wise. Instead, seek what they sought." - Matsuo Basho
November 11, 2016 at 3:50 pm
Someone at works tells me he has experience of http://www.dpriver.com/pp/sqlformat.htm and likes it.
Since we don't have much time for experimentation, we might give that one a shot first.
I like the fact that there is an add-in for both Visual Studio and SSMS...
Thanks a lot for your help
Much appreciated
November 11, 2016 at 7:17 pm
Eric M Russell (11/11/2016)
Jeff Moden (11/11/2016)
Eric Mamet (11/10/2016)
Can someone recommend a (free?) tool to format TSQL Code.Ideally, it should be something working in both SSMS and Visual Studio (SSDT) as we use both for our TSQL Code.
This would help us with coding standards, debugging, etc.
Thanks
A bit ironic, I think. If you have coding standards, why aren't people following them?
Can you tell the difference between artisanal hand-coded SQL that someone slaved over for an hour just to get all the keywords capitalized and the tabs lined up, versus SQL auto-formatted by a tool configured to match your coding standards? 🙂
Just my humble opinion... If someone has to slave over such a simple thing, they may not have been at it long enough or the standard is bad. If the standard is good, it should come naturally.
I've also found that I can, indeed, frequently tell the difference between someone that used a formatting tool and someone that did not even when both are formatted identically.
--Jeff Moden
Change is inevitable... Change for the better is not.
November 12, 2016 at 3:17 am
Jeff Moden (11/11/2016)
Eric M Russell (11/11/2016)
Jeff Moden (11/11/2016)
Eric Mamet (11/10/2016)
Can someone recommend a (free?) tool to format TSQL Code.Ideally, it should be something working in both SSMS and Visual Studio (SSDT) as we use both for our TSQL Code.
This would help us with coding standards, debugging, etc.
Thanks
A bit ironic, I think. If you have coding standards, why aren't people following them?
Can you tell the difference between artisanal hand-coded SQL that someone slaved over for an hour just to get all the keywords capitalized and the tabs lined up, versus SQL auto-formatted by a tool configured to match your coding standards? 🙂
Just my humble opinion... If someone has to slave over such a simple thing, they may not have been at it long enough or the standard is bad. If the standard is good, it should come naturally.
+1, I find a strong correlation between consistent code formatting and standard compliance, gives a kind of a first impression when reviewing code.
😎
I've also found that I can, indeed, frequently tell the difference between someone that used a formatting tool and someone that did not even when both are formatted identically.
When writing a well formatted code, which is easy with column editing, spaces rather than tabs etc., one has an added opportunity to review and assert the code at the same time, I discover most of my coding errors during the actual writing rather than testing of the code.
November 12, 2016 at 8:33 am
Eirikur Eiriksson (11/12/2016)
I've also found that I can, indeed, frequently tell the difference between someone that used a formatting tool and someone that did not even when both are formatted identically.
When writing a well formatted code, which is easy with column editing, spaces rather than tabs etc., one has an added opportunity to review and assert the code at the same time, I discover most of my coding errors during the actual writing rather than testing of the code.
+1 Billion. That's exactly what I'm talking about. I've reviewed volumes of code that contains obvious errors and has no chance of performance but is pretty as hell because someone used a tool to format their junk. The person that does their own formatting may take a bit longer but they also typically produce error free code simply because of what you stated.
I've also found it to be the nature of artisans of code to also test their code whereas people who "just write code" do not. It's an attitude/pride thing that goes a long way to preventing the need for rework.
--Jeff Moden
Change is inevitable... Change for the better is not.
November 13, 2016 at 9:46 pm
Have used the tool for years. Strange name I will give you that but it works great and has every option you can imagine.
http://www.dpriver.com/pp/sqlformat.htm
<hr noshade size=1 width=250 color=#BBC8E5> Regards,Jeffery Williams http://www.linkedin.com/in/jwilliamsoh
November 15, 2016 at 9:42 am
I'm a fan of Notepad++ and the Poor Man's T-SQL Formatter. While I could spend the time to make pretty code I'd much rather take my messy working code and let the formatter do the work. I don't want to spend the time formatting it when there's a free tool that does it for me.
November 15, 2016 at 9:46 am
Jeffery Williams (11/13/2016)
Have used the tool for years. Strange name I will give you that but it works great and has every option you can imagine.
This is the one my colleague recommended and we are trying it
Viewing 15 posts - 1 through 15 (of 16 total)
You must be logged in to reply to this topic. Login to reply