SQL Server Forums
Profile | Register | Active Topics | Members | Search | Forum FAQ
 
Register Now and get your question answered!
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 Other Forums
 Other Topics
 SQL Indenter
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

bba
Starting Member

3 Posts

Posted - 05/23/2003 :  13:55:48  Show Profile  Reply with Quote
Hi All,

Is there any freeware tool/utility available to indent/format the stored procedures. I have quite a few SPs developed by the previous developers that are not indented. I used sp_helptext to retrieve the source code for some SPs. SQL server does not indent them either.

Any help is greatly appreciated.

Regards
BBA

robvolk
Most Valuable Yak

USA
15676 Posts

Posted - 05/24/2003 :  16:03:54  Show Profile  Visit robvolk's Homepage  Reply with Quote
There's this neat feature available on most computer keyboards, called the TAB key. It does an excellent job of indenting.

I don't want to sound rude or anything, but indenting won't turn an incomprehensible procedure into a comprehensible one; you either understand what it does or you don't. If you don't, the best way to understand what it does is to go through it line-by-line and indent it yourself.

Go to Top of Page

nr
SQLTeam MVY

United Kingdom
12543 Posts

Posted - 05/24/2003 :  20:43:36  Show Profile  Visit nr's Homepage  Reply with Quote
>> but indenting won't turn an incomprehensible procedure into a comprehensible one.
Disagree - it can but only if it's incomprehensible due to formatting.

I also discovered that you can indent blocks by highlighting the block and hitting the tab key.
Not sure when but an embarrassingly long time after the feature must have been included.


==========================================
Cursors are useful if you don't know sql.
DTS can be used in a similar way.
Beer is not cold and it isn't fizzy.
Go to Top of Page

Arnold Fribble
Yak-finder General

United Kingdom
1961 Posts

Posted - 05/25/2003 :  06:27:59  Show Profile  Reply with Quote
I'm pretty sure that was an addition to the client tools for SQL Server 2000. I take it you know that shift-tab unindents in the same way?


Go to Top of Page

dsdeming
Constraint Violating Yak Guru

USA
479 Posts

Posted - 05/27/2003 :  08:00:18  Show Profile  Reply with Quote
quote:
I take it you know that shift-tab unindents in the same way?



Oops! I've been using block indent for a long time now and for just as long I've been grumbling about the lack of a block un-indent. Thanks, Arnold.

Go to Top of Page

bba
Starting Member

3 Posts

Posted - 05/29/2003 :  15:40:49  Show Profile  Reply with Quote
Thanks for your inputs. Actually, my boss has asked me to write a tool to do it , so other departments/locations can also reuse it. I thought if something already exists, I need not write it.

Any help is greatly appreciated.

--bba

Go to Top of Page

Page47
Flowing Fount of Yak Knowledge

USA
2878 Posts

Posted - 05/30/2003 :  07:22:56  Show Profile  Reply with Quote
quote:

...but indenting won't turn an incomprehensible procedure into a comprehensible one...



CREATE TABLE #n (n int PRIMARY KEY) INSERT #n
SELECT 1 UNION SELECT 2 UNION SELECT 3 UNION SELECT 4
UNION SELECT 5 SELECT CASE WHEN o=a THEN 'DK' WHEN o=b
THEN 'EN' WHEN o =c THEN 'DE' WHEN o=d THEN
'NO'ELSE'SE' END yak FROM (SELECT a.n a ,b.n b,c.n
c,d.n d,15 -a.n-b.n -c.n-d. n e,e.n f,f. n g,g.n h,
h.n i,15 -e.n-f.n-g.n-h.n j,i .n k,j.n l ,k.n m,l.n
n,15-i. n-j.n-k.n-l.n o,m.n p,n.n q,o.n r, p.n s,15
-m.n-n.n -o.n-p.n t,q.n u, r.n v,s. n w,t. n x,15
-q.n-r.n -s.n-t.n y FROM #n a,#n b,#n c, #n d,#n
e,#n f, #n g,#n h, #n i,#n j,#n k, #n l,#n
m,#n n, #n o,#n p,#n q, #n r,#n s,#n t) z WHERE
NOT(b=a OR c IN (a,b)OR d IN(a, b,c))AND NOT(g=

f OR h IN(f,g)OR i IN(f,g,h))AND NOT(l=k OR m IN(k,l)OR n IN(k,l,m))AND NOT(q
=p OR r IN(q,p)OR s IN(q,p,r))AND NOT(v=u OR w IN(u,v)OR x IN(u,v,w))AND q=g
AND x=k AND j=w AND r=3 AND d=1 AND v=p AND 1=ABS(u-l)AND g=i-1 AND 1=ABS(n-w)
AND c=y AND 1=ABS(d-f)AND e=m AND 1=ABS(t-u)AND a=s AND b=h DROP TABLE #n

 


Jay White
{0}
Go to Top of Page

Andraax
Aged Yak Warrior

Sweden
790 Posts

Posted - 05/30/2003 :  07:30:25  Show Profile  Reply with Quote
LOL... That was nice! Reminds me of competition we had in school, where we were supposed to write the most unreadable C++ program...

Go to Top of Page

Arnold Fribble
Yak-finder General

United Kingdom
1961 Posts

Posted - 05/30/2003 :  07:41:40  Show Profile  Reply with Quote
Unreadable? Ok, they're ugly letters -- with long keywords and no macro language it was never going to look great -- but it's perfectly readable to me.


Edited by - Arnold Fribble on 05/30/2003 07:44:30
Go to Top of Page

dtecmeister
Starting Member

USA
5 Posts

Posted - 05/13/2010 :  22:23:36  Show Profile  Reply with Quote
This is a bit late, but I ran into the same issues and created a fast SQL indenter that works on .cs files as well and comments where end blocks are not already commented in addition to the indentation formating. It's available for free and is here:
http://www.softfrontiers.com/Downloads/ReIndenter.shtml

Thanks and enjoy!
Jeff Doak
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.19 seconds. Powered By: Snitz Forums 2000