SQL Clone
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


Code Formatting


Code Formatting

Author
Message
StarNamer
StarNamer
SSCrazy
SSCrazy (2.7K reputation)SSCrazy (2.7K reputation)SSCrazy (2.7K reputation)SSCrazy (2.7K reputation)SSCrazy (2.7K reputation)SSCrazy (2.7K reputation)SSCrazy (2.7K reputation)SSCrazy (2.7K reputation)

Group: General Forum Members
Points: 2710 Visits: 1992
GilaMonster (3/18/2009)
Steve Jones - Editor (3/17/2009)
New code formatting has been released on SSC.


Ooooohhhh..... Nice!

Jack Corbett (3/17/2009)
This has been a light day for me posting code. I've mainly added links.


I don't think I've posted any code this week yet.


If you look, you'll find that all existing code is now being displayed with color highlighting...

I wonder if that's broken anything? I think I may have used a construct like

[ c o d e ] ..... ; [ b ] [ / b ] ) ... [ / c o d e ]

and relied on the bold tag getting hidden! I will have to go look...

Derek
GilaMonster
GilaMonster
SSC Guru
SSC Guru (216K reputation)SSC Guru (216K reputation)SSC Guru (216K reputation)SSC Guru (216K reputation)SSC Guru (216K reputation)SSC Guru (216K reputation)SSC Guru (216K reputation)SSC Guru (216K reputation)

Group: General Forum Members
Points: 216025 Visits: 46275
I think the string and comment handling needs a little more work
http://www.sqlservercentral.com/Forums/FindPost678555.aspx

--here's a single quote within a comment
select 'String 1', 012
select 'String 3', 789 -- that's not what I wanted to see
select 'String 5', 456 -- that's better
select 'String 7', 123 -- not quite



Gail Shaw
Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability

We walk in the dark places no others will enter
We stand on the bridge and no one may pass


StarNamer
StarNamer
SSCrazy
SSCrazy (2.7K reputation)SSCrazy (2.7K reputation)SSCrazy (2.7K reputation)SSCrazy (2.7K reputation)SSCrazy (2.7K reputation)SSCrazy (2.7K reputation)SSCrazy (2.7K reputation)SSCrazy (2.7K reputation)

Group: General Forum Members
Points: 2710 Visits: 1992
Bob posted some code here. Bob's code looks OK, but I think the formatter saw a single quote in the comment and hence was thown out of phase.


-- based on what we've seen
insert #t
select 'this is how' union all
select 'we insert data' union all
select 'for testing'

declare @i int
-- wouldn't it be nice to insert arrays so you didn't need to do union all
set @i = 1
select k as 'kay'

/*
block comments aren't right either
what happens if I insert one
*/
select j as 'jay'



Basically, it looks like the scanner is recognizing single quotes in comments and hence getting confused. I've attache a screenshot previewing the above rather than try to describe it.

Derek
Attachments
ssc screenshot 2.bmp (15 views, 890.00 KB)
Lowell
Lowell
SSC Guru
SSC Guru (68K reputation)SSC Guru (68K reputation)SSC Guru (68K reputation)SSC Guru (68K reputation)SSC Guru (68K reputation)SSC Guru (68K reputation)SSC Guru (68K reputation)SSC Guru (68K reputation)

Group: General Forum Members
Points: 68962 Visits: 40915
i noticed if i add an 800 line [code] block, it'll show all 800 lines; i'd rather have a scrollbar for the code in question, if possible.

Lowell
--help us help you! If you post a question, make sure you include a CREATE TABLE... statement and INSERT INTO... statement into that table to give the volunteers here representative data. with your description of the problem, we can provide a tested, verifiable solution to your question! asking the question the right way gets you a tested answer the fastest way possible!
Lynn Pettis
Lynn Pettis
SSC Guru
SSC Guru (91K reputation)SSC Guru (91K reputation)SSC Guru (91K reputation)SSC Guru (91K reputation)SSC Guru (91K reputation)SSC Guru (91K reputation)SSC Guru (91K reputation)SSC Guru (91K reputation)

Group: General Forum Members
Points: 91672 Visits: 38953
Copying and pasting code from the forum, the code becomes double spaced and it loses it formatting (indention for one).

Cool
Lynn Pettis

For better assistance in answering your questions, click here
For tips to get better help with Performance Problems, click here
For Running Totals and its variations, click here or when working with partitioned tables
For more about Tally Tables, click here
For more about Cross Tabs and Pivots, click here and here
Managing Transaction Logs

SQL Musings from the Desert Fountain Valley SQL (My Mirror Blog)
Steve Jones
Steve Jones
SSC Guru
SSC Guru (141K reputation)SSC Guru (141K reputation)SSC Guru (141K reputation)SSC Guru (141K reputation)SSC Guru (141K reputation)SSC Guru (141K reputation)SSC Guru (141K reputation)SSC Guru (141K reputation)

Group: Administrators
Points: 141898 Visits: 19420
Lowell, good point. We should probably limit areas to 40-50 lines tops.

Follow me on Twitter: @way0utwest
Forum Etiquette: How to post data/code on a forum to get the best help
My Blog: www.voiceofthedba.com
StarNamer
StarNamer
SSCrazy
SSCrazy (2.7K reputation)SSCrazy (2.7K reputation)SSCrazy (2.7K reputation)SSCrazy (2.7K reputation)SSCrazy (2.7K reputation)SSCrazy (2.7K reputation)SSCrazy (2.7K reputation)SSCrazy (2.7K reputation)

Group: General Forum Members
Points: 2710 Visits: 1992
Since the formatting is active for historical code, you also have interesting effects where the 'code' wasn't t-sql, for example
http://www.sqlservercentral.com/Forums/FindPost661664.aspx


Or where I inserted 'font' tags in the code to produce a color effect, which of course, are now visible.
http://www.sqlservercentral.com/Forums/FindPost669471.aspx

Derek
StarNamer
StarNamer
SSCrazy
SSCrazy (2.7K reputation)SSCrazy (2.7K reputation)SSCrazy (2.7K reputation)SSCrazy (2.7K reputation)SSCrazy (2.7K reputation)SSCrazy (2.7K reputation)SSCrazy (2.7K reputation)SSCrazy (2.7K reputation)

Group: General Forum Members
Points: 2710 Visits: 1992
How easy would it be to revert the [ code ][ /code ] tags to work as before and add a new set of [ tsql ][ /tsql ] tags?

Hence old usage wouldn't break and people could preview that new [ tsql ] sections were valid.

Derek
Steve Jones
Steve Jones
SSC Guru
SSC Guru (141K reputation)SSC Guru (141K reputation)SSC Guru (141K reputation)SSC Guru (141K reputation)SSC Guru (141K reputation)SSC Guru (141K reputation)SSC Guru (141K reputation)SSC Guru (141K reputation)

Group: Administrators
Points: 141898 Visits: 19420
I shall ask

There should be a [ code2 ] set of tags for XML as well.

Follow me on Twitter: @way0utwest
Forum Etiquette: How to post data/code on a forum to get the best help
My Blog: www.voiceofthedba.com
Michael Valentine Jones
Michael Valentine Jones
SSChampion
SSChampion (13K reputation)SSChampion (13K reputation)SSChampion (13K reputation)SSChampion (13K reputation)SSChampion (13K reputation)SSChampion (13K reputation)SSChampion (13K reputation)SSChampion (13K reputation)

Group: General Forum Members
Points: 13949 Visits: 11848
It doesn't seem to handle tab indents very well. The indents below are all over the place, even though they are all a single tab character.

I think it would be easier to read with a non-proportional font for the display, since that is usually the way we usually see it in a code editor.

select
*
from
Mytable
where
MyColumn1 in (1,2)
order by
MyColumn33


Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum

































































































































































SQLServerCentral


Search