Silverkight Viewer for Reporting Services
Got a SQL Server or .NET question? Discuss it in the forums. (SQL Server Forums | Dot NET Forums)
First Time? You can support us by signing up. It takes only 5 seconds. Click here to sign up. If you already have an account, click here to login.

Formatting your code when posting in the forums

rated by 0 users
This post has 8 Replies | 2 Followers

Top 10 Contributor
Male
Posts 1,524
Points 22,731
Jacob Sebastian Posted: 01-28-2010 4:32 AM

When posting questions in the forums with TSQL code, it may be a good idea to format your code so that it looks better in the forums. When the code is formatted and keywords are colored, it will make the code easier to understand.

You can add formatting to the code by placing your code between a <pre> block. Here is an example of a piece of code that uses formatting tags.

<pre class="brush:sql">
-- Check current time
SELECT GETDATE()
</pre>

The above code will be formatted and printed as follows in the forums

-- Check current time
SELECT GETDATE()

Jacob Sebastian, SQL Server MVP

See this post that explains how to format TSQL code listing when posting in this forum.

  • | Post Points: 20
Top 10 Contributor
Male
Posts 186
Points 2,805

Thanks, But sometimes evethough I do it, by default it adds this tag

<divre...>...</divre>

Any reason?

  • | Post Points: 20
Top 10 Contributor
Male
Posts 1,524
Points 22,731
I think it is the editor control that does it. The best is to compose your text and then go to 'html' view(there is a button on the toolbar of the editor) and paste the tsql code within the <pre> block.

Jacob Sebastian, SQL Server MVP

See this post that explains how to format TSQL code listing when posting in this forum.

  • | Post Points: 20
Top 10 Contributor
Male
Posts 186
Points 2,805

Yes. Usually I do this only

  • | Post Points: 20
Top 50 Contributor
Female
Posts 34
Points 525

I tried several times to set my text correctly using HTML editor, but it didn't work :( I'm using IE 8 and I tried to do everything in the HTML editor - it still didn't work after I pressed 'Update' button.

  • | Post Points: 20
Top 10 Contributor
Male
Posts 1,524
Points 22,731
You need to insert the "pre" blocks by going to the HTML source page rather than the wysiwyg editor. It is a little awkward. If you use Windows Live writer to compose your blog posts, then it will be much easier. you can use the plugin given here: http://www.codeplex.com/wlwSyntaxHighlighter

Jacob Sebastian, SQL Server MVP

See this post that explains how to format TSQL code listing when posting in this forum.

  • | Post Points: 20
Top 50 Contributor
Female
Posts 34
Points 525

I was doing it directly in the editor you have on this site, then pressing Html button, then inserting pre tags there, then pressing update. It didn't work and when I went back to HTML view I saw divpre tag instead of pre tag I put.

  • | Post Points: 5
Top 50 Contributor
Female
Posts 34
Points 525

Test of the code here.

select @@VERSION 
  • | Post Points: 20
Top 10 Contributor
Male
Posts 1,524
Points 22,731
Correct, this one works. You can find an option in the profile to select the editor you wish to use. (wysiwyg or html).

Jacob Sebastian, SQL Server MVP

See this post that explains how to format TSQL code listing when posting in this forum.

  • | Post Points: 5
Page 1 of 1 (9 items) | RSS

Copyright © Beyondrelational.com