Loading
Showing posts with label Format for Blog. Show all posts
Showing posts with label Format for Blog. Show all posts

Tuesday, November 17, 2009

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:\Backups\AdventureWorks.BAK'

To this one formatted to appear like SQL management tools:

BACKUP DATABASE AdventureWorks
TO DISK = 'C:\Backups\AdventureWorks.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:\Backups\AdventureWorks.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:\Backups\AdventureWorks.BAK'</span></code>