Format SQL statements with HTML to look like SQL Server Management Studio

Have you ever tried to post a SQL statement in a blog or web page, but cannot figure out how to format it to look like it does in SQL Server Management Studio or Query Analyzer?

Compare this statement:

BACKUP DATABASE AdventureWorks
TO DISK = ‘C:BackupsAdventureWorks.BAK’

To this one formatted to appear like SQL management tools:

BACKUP DATABASE AdventureWorks
TO DISK = 'C:BackupsAdventureWorks.BAK'

Here’s the HTML – just substitute your commands.

Line 1 (BACKUP DATABASE AdventureWorks):

<code><span lang=”EN-US” style=”color: blue; font-size: 10pt;”>BACKUP DATABASE</span></code> <code><span lang=”EN-US” style=”color: black; font-size: 10pt;”>AdventureWorks</span></code><span lang=”EN-US” style=”color: black; font-family: ‘Courier New’; font-size: 10pt;”></span>

Line 2 (TO DISK = 'C:BackupsAdventureWorks.BAK'):

<code><span lang=”EN-US” style=”color: blue; font-size: 10pt;”>TO DISK =</span></code> <code><span lang=”EN-US” style=”color: red; font-size: 10pt;”>’C:BackupsAdventureWorks.BAK'</span></code>

Leave a Reply

Your email address will not be published. Required fields are marked *