March 19, 2012 at 2:49 pm
Online - doesn't plug in to SQL Server Tools, but useful for a quick format of T-SQL:
--Also worth noting that if someone used comments within the T-SQL, it could fail to format.
March 19, 2012 at 2:57 pm
Peter Schott (3/19/2012)
Online - doesn't plug in to SQL Server Tools, but useful for a quick format of T-SQL:--Also worth noting that if someone used comments within the T-SQL, it could fail to format.
Thanks for the prompt reply. Comments shouldn't be a problem in this situation. Not sure whether to laugh or weep at this.
March 19, 2012 at 3:01 pm
It's come in handy for me on several occasions. Embedded SQL seems to be the main use, but sometimes a copy/paste doesn't pick up the line formats or I'm reading off a SQL Trace where the formatting is lost. I have found some issues with the single-line comments (--). You'll need to break those out onto their own lines for the formatting to work properly if the line breaks are lost. Outside of that, it works well and I don't see how any parser would determine between comment and code if that's in line. 🙂
March 19, 2012 at 3:12 pm
Rose Bud (3/19/2012)
Peter Schott (3/19/2012)
Online - doesn't plug in to SQL Server Tools, but useful for a quick format of T-SQL:--Also worth noting that if someone used comments within the T-SQL, it could fail to format.
Thanks for the prompt reply. Comments shouldn't be a problem in this situation. Not sure whether to laugh or weep at this.
Weep! Unless it's so darn obvious what it does.:-)
March 19, 2012 at 5:30 pm
SQLRNNR (3/19/2012)
Nadrek (3/18/2012)
My answer to tabs vs. spaces, case convention, and pre vs post commas is always to let a computer do tedious, menial, purely rules based work - use a SQL beautifier/formatter. If someone else doesn't like your settings, they can use _their_ settings. None of that matters to the SQL parsing engine, so why should it matter to us?
+1:-D
Heh... -1. To do it right, IMHO, you should write code for humans, not for the computer, because humans have to maintain the code. If you wanted to write code for the computer, you'd be using raw machine language.
I have a huge personal dislike for things like leading commas and the reasons why people think it's a good idea to use them but I'm not one to judge code based on such a personal preference. Seeing virtually any type of decent formatted code is a joy compared to some of the stuff I have seen on these forums and in real life. 😀
--Jeff Moden
Change is inevitable... Change for the better is not.
March 19, 2012 at 5:39 pm
MarbryHardin (3/19/2012)
Tabs, all the way.Saying that you want to use spaces because people will write improperly formatted code is a hack. Tabs have the same usefulness and purpose in writing SQL as they do in C#. The people that will use spaces where they should have tabs probably won't use either correctly (if at all), so why would you want to deliberately shoot yourself in the knee for them?
Spaces are a cop out. Next thing you know you'll be recommending cursors because someone may someday work on the code that doesn't understand other constructs. 😉
As Lynn said, that's really an apples/oranges comparison but I appreciate the passion.
SQL Server very nicely works with tabs converted to spaces and comes in real handy when you open code that has different tabs stops set. I prefer mine to be set at 4, some go with the default of 8. Both settings play hell on your code if you need to quickly open something up with Notepad which has a default of 15.
--Jeff Moden
Change is inevitable... Change for the better is not.
March 19, 2012 at 10:45 pm
We are using Space instead of Tab. Reason: code looks perfect in any editor.
To replace the tab with space, SSMS provides "Untabify Selected Lines" option. Only problem this option has is it is not replacing tab with space in comments. For that we can use Visual Studio editor - same option.
Also we can insert space instead of tab by setting SSMS options.
Thanks
March 20, 2012 at 2:16 am
I say pick a standard and stick to it. It doesn't matter which one, as long as everybody uses the same one.
March 20, 2012 at 4:07 am
I think the point about using non-default settings is the crucial one - I can persuade people to format code half decently but getting them to change default settings seems trickier, and space formatted layouts become unmaneageable without changing settings.
We all use Notepad++ here if not using SSMS, which deals with tabs admirably. I'd recommend downloading it - now! - if you are still stuck using Notepad.
March 20, 2012 at 6:30 am
Jeff Moden (3/19/2012)
Seeing virtually any type of decent formatted code is a joy ... 😀
+1
My coworkers laugh at me because before I'll even begin troubleshooting their code, I'll format it quickly so that I can see what I'm looking at. It would be some much easier if they picked any type of formatting, doesn't have to be the formatting I'm accustomed to.
March 20, 2012 at 6:31 am
Rose Bud (3/19/2012)
Can anyone recommend a free or very inexpensive SQL Beautifier/Formatter which works well with complex queries? One that integrated with SSMS 2008 would be ideal.
I *love* SQL Prompt from RedGate, it's not terribly expensive and the Format SQL command has a two-keystroke shortcut (^K^Y). Does a bunch of other stuff too like enhancing intellisense. And it integrates into SSMS.
March 20, 2012 at 10:22 am
i prefer tabs to spaces.
main reason is probably because i can highlight multiple rows and tab them across where as if i did that with the spacebar it would delete the rows.
also because i think its easier to align rows with tabs.
March 20, 2012 at 10:43 am
davidandrews13 (3/20/2012)
i prefer tabs to spaces.main reason is probably because i can highlight multiple rows and tab them across where as if i did that with the spacebar it would delete the rows.
also because i think its easier to align rows with tabs.
In SSMS, highlight those rows and hit tab to move across or shift+tab to move left... I use spaces all the time and have zero deletions.
March 20, 2012 at 2:32 pm
Heh, anyone else agree that anything produced by the Query Designer is visually heinous?
March 20, 2012 at 3:06 pm
This was entertaining - kind of like 'The Crusades' in the middle ages ...
RegardsRudy KomacsarSenior Database Administrator"Ave Caesar! - Morituri te salutamus."
Viewing 15 posts - 31 through 45 (of 49 total)
You must be logged in to reply to this topic. Login to reply