Notes on SQL

Random articles from a puzzled DBA

Well that was fun. Setting up the WordPress account was quite straightforward and there’s plenty of material out there about creating a basic post for it.
However, I wanted to be able to include SQL code that could be copied by anybody reading the article – much friendlier than making them type it back out themselves from a screen-shot.
It took a little bit of hunting and of course there is an article within the numerous WordPress support articles. The trick is to get the correct phrasing through Google.

I have three links to articles on this feature:
http://allaboutruby.wordpress.com/2009/06/26/post-ruby-or-html-css-sql-code-in-your-wordpress-com-blog/
http://en.support.wordpress.com/code/posting-source-code/
http://thesqlguy.wordpress.com/2011/06/20/publishing-source-code-to-wordpress-using-windows-live-writer-2011/
So to get the following code to appear in the correct colours and with the facility for it to be copied:
SELECT *
FROM INFORMATION_SCHEMA.COLUMNS
WHERE COLUMN_NAME LIKE ‘%test%’
Place the correct tags around the code:

wordpress01

And it will appear as:

SELECT *
FROM INFORMATION_SCHEMA.COLUMNS
WHERE COLUMN_NAME LIKE '%test%'

Unfortunately, what I can’t find is any way to keep the formatting when using copy/paste into SSMS. Trying that produces the code on one long line. So for now, I’ll just have to try and remember to leave a space at the start of each line. Then at least the code will parse correctly (I’m not promising anything will actually execute correctly!).

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.

%d bloggers like this: