Categories
Blog Format for Blog HTML Linux SQL Windows

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>

Categories
HTML Javascript Linux Windows Windows 2000

Display Today’s (Current) Date Dynamically in HTML Pages

The Easy Way

<script language="javascript">
<!--
document.write(Date());
-->
</script>

The easy way provides date, time and timezone information. If you want to display the date only, the following way will do that.

The Hard Way

<script language="javascript">
<!--
Today = new Date();

TodayDay = Today.getDate();
TodayMon = Today.getMonth();
TodayYear = Today.getYear();
if (TodayYear < 2000) TodayYear += 1900;

if (TodayMon == 0) { TodayMonth = "January"; }

else if (TodayMon == 1) { TodayMonth = "February"; }
else if (TodayMon == 2) { TodayMonth = "March"; }
else if (TodayMon == 3) { TodayMonth = "April"; }
else if (TodayMon == 4) { TodayMonth = "May"; }
else if (TodayMon == 5) { TodayMonth = "June"; }
else if (TodayMon == 6) { TodayMonth = "July"; }

else if (TodayMon == 7) { TodayMonth = "August"; }
else if (TodayMon == 8) { TodayMonth = "September"; }
else if (TodayMon == 9) { TodayMonth = "October"; }
else if (TodayMon == 10) { TodayMonth = "November"; }
else if (TodayMon == 11) { TodayMonth = "December"; }
else { TodayMonth = TodayMon; }

document.write(TodayMonth + " " + TodayDay + ", " + TodayYear);

-->
</script>