Nicely Formatted HTML Email of SQL Table
Produced: 30/03/2014 16:49:00
Okay, in my last post I showed you how easy it is to include a table of results in an email, but by all accounts it was a little bit bland when produced. So in this post I’ll deviate a little from SQL Server to give you some HTML which will

Continued...
SQL Table of Results in an HTML email
Produced: 23/03/2014 16:44:00
To be honest I couldn’t think of a good title for this particular post so I’ve gone with the above. Basically what I’m referring to is that sometimes a simple text email isn’t enough and you want to include some output with it… therefore what you need is a table.

Creating a table in an email body is not the simplest of things and I’ve seen numerous people struggle to create one, ending up doing something incredibly complex with their output, or even trying external plugins.

Continued...
SQL Column to Comma Separated List
Produced: 16/03/2014 17:57:00
This is a handy little “trick” which I use all the time when I need to turn the column of a table into a comma separated list. It’s incredibly quick, has very little overhead, and it’s effective.

Continued...
sp_Merge
Produced: 09/03/2014 17:51:00
There are numerous times in which I, and many devs in the company, need to merge new data into existing tables and prior to the MERGE command this tended to be done in a procedure which created a “dev” table (table prefixed with “dev_”), executed multiple comparisons and joins, and then proceeded to perform an sp_rename to swap the dev table for the live one.

In comparisons, the MERGE statement out performed this proc by a country mile and therefore the recommendation was to move to this style of code. However, the code is quite long winded and people weren’t using it. Hence sp_merge.

Continued...
Different Query Results with row_number
Produced: 02/03/2014 18:30:00
Today I was asked a question that left me baffled for a good few minutes whilst trying to come up with an answer. Sadly my mistake all along was that I trusted a developer. Ah well, happens to everyone sometimes.

Basically the issue was that QA had noticed that there were inconsistencies with data between our staging and QA servers. Obviously this shouldn’t be the case and the developers tracked it down to a specific stored procedure… one server returned one set of results, the other server a different set. Therefore the issue ended at my doorstep.

Initially it was a simple case of running the proc on a variety of test servers… initially all gave the same result and I was left completely baffled as to the problem. But then, when re-running the query, suddenly my results changed.

Continued...