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:
So to get the following code to appear in the correct colours and with the facility for it to be copied:
WHERE COLUMN_NAME LIKE ‘%test%’
Place the correct tags around the code:
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!).