June 9, 2008 at 2:56 pm
Hello All,
Please hopefully somebody has figured out how to stop SQL Server 2005 from auto formatting all my SQL when I validate and/or save. Currently this means that I developer in NotePad++, copy/past, execute, return to NotePad++ for editing.
Becomes quite tedious. I know I can use the "new query" option as well, but still find this hyperannoying.
Any tips on how to disable it, and/or even tweak it so it carriage returns on more common clauses too?
Thanks,
Michael Lowden
June 9, 2008 at 3:06 pm
Not sure what you mean. SQL-server never reformats my procedures and views.
Can you give a step-by-step example?
[font="Times New Roman"]-- RBarryYoung[/font], [font="Times New Roman"] (302)375-0451[/font] blog: MovingSQL.com, Twitter: @RBarryYoung[font="Arial Black"]
Proactive Performance Solutions, Inc. [/font][font="Verdana"] "Performance is our middle name."[/font]
June 9, 2008 at 3:08 pm
Are you using the GUI to design views or something? I'm asking because the "right-click, Edit" option for procs/views/etc., doesn't do any reformatting that I'm aware of.
- Gus "GSquared", RSVP, OODA, MAP, NMVP, FAQ, SAT, SQL, DNA, RNA, UOI, IOU, AM, PM, AD, BC, BCE, USA, UN, CF, ROFL, LOL, ETC
Property of The Thread
"Nobody knows the age of the human race, but everyone agrees it's old enough to know better." - Anon
June 9, 2008 at 3:14 pm
wow... thanks for the quick followups guys.
------------------------------------
Right-Click > New View
.. add a simple table like "country"
Type your own SQL in the editor (3rd of 4 panes) and enter:
SELECT
Name, CountryID
FROM
Country
WHERE
(
Name='Canada'
OR
Name='United States'
.) --- ignore the '.'
AND
(
'just because' = 'just because'
.) --- ignore the '.'
Validate the code with the little SQL Checkmark thingy 😉
and notice that it's re-written the SQL to be:
SELECT Name, CountryID
FROM dbo.Country
WHERE (Name = 'Canada' OR
Name = 'United States') AND ('just because' = 'just because')
Not major in this example, but when I have a few hundred lines of syntax I completely lose handles on where in my code stuff is. So i have to keep TXT (.sql) files around for everything, "just in case" I need to do editing.
-- ignore the DOT because this site was converting my close paren ")" into smiley's 😉
June 9, 2008 at 3:37 pm
Ah, yes. You are using the View wizard as GSquared surmised.
Here's how to fix that: Never use the View wizard. Use query windows instead.
The View wizard is really awful once you know what you are doing, but people get used to it and think that they cannot get along without it. Just lose it. The View wizard is like training wheels on a bicycle: they seem like they are helping you at first, but very quickly they start getting in your way, slowing you down, and actually prevent you from doing what you really want to.
[font="Times New Roman"]-- RBarryYoung[/font], [font="Times New Roman"] (302)375-0451[/font] blog: MovingSQL.com, Twitter: @RBarryYoung[font="Arial Black"]
Proactive Performance Solutions, Inc. [/font][font="Verdana"] "Performance is our middle name."[/font]
June 9, 2008 at 3:44 pm
As already mentioned, don't use the view wizard. Write the queries yourself.
I've actually seen the view wizard break queries that were already working.
- Gus "GSquared", RSVP, OODA, MAP, NMVP, FAQ, SAT, SQL, DNA, RNA, UOI, IOU, AM, PM, AD, BC, BCE, USA, UN, CF, ROFL, LOL, ETC
Property of The Thread
"Nobody knows the age of the human race, but everyone agrees it's old enough to know better." - Anon
June 9, 2008 at 3:46 pm
Oh I totally agree. But really isn't it the only way to create a view without typing the supporting TSQL for like "CREATE VIEW" etc?
Or is there some higher power option like "Do not use SQL Wizard" option?
June 9, 2008 at 4:58 pm
Michael.Lowden (6/9/2008)
Oh I totally agree. But really isn't it the only way to create a view without typing the supporting TSQL for like "CREATE VIEW" etc?
Yes, you have to type three extra words:
CREATE VIEW {view_name} AS {view_definition}
The {view_defintion} is what you are cutting and pasting from Notpad++, so that's the same. The {view_name} is what you have to type in now when you save. So in total, it's 3 more words. A very small price to pay in order to be free of the View Wizard. You might even find that you can just develop in the Query window and cut out the extra steps you are doing today (that's what 90% of us do).
Or is there some higher power option like "Do not use SQL Wizard" option?
I wish!
[font="Times New Roman"]-- RBarryYoung[/font], [font="Times New Roman"] (302)375-0451[/font] blog: MovingSQL.com, Twitter: @RBarryYoung[font="Arial Black"]
Proactive Performance Solutions, Inc. [/font][font="Verdana"] "Performance is our middle name."[/font]
June 9, 2008 at 5:06 pm
HAHA. fair enough. I guess I just prefer the features of TXT/SQL editing in a more advanced TXT editor ... you know with options like "Insert 2 spaces instead of TABs".
But then again, I still program almost everything by hand in there. From BackEnds to FrontEnds baby. Did I mention that Courier is still my most favourite font ... fixed width is the only way to go. That may make me a pretty hefty geek i know, but hey, i'm okay with that.
Thanks for the attention all.
Mike.
June 9, 2008 at 5:42 pm
If you prefer your own editor, that's great. Many do still use custom editors. But the Wizards are another story, ultimately, they are just limiting.
[font="Times New Roman"]-- RBarryYoung[/font], [font="Times New Roman"] (302)375-0451[/font] blog: MovingSQL.com, Twitter: @RBarryYoung[font="Arial Black"]
Proactive Performance Solutions, Inc. [/font][font="Verdana"] "Performance is our middle name."[/font]
Viewing 10 posts - 1 through 10 (of 10 total)
You must be logged in to reply to this topic. Login to reply