Category Archives: T-SQL Code Examples

A Little Fun With DateTime

A colleague asked me how to get the last day of the month for the current month using T-SQL. It’s an interesting problem, myself and another colleague both gave different answers to his question (which just goes to show that … Continue reading

Posted in T-SQL Code Examples | Tagged , , , , | Leave a comment

Changes To Exception Handling In SQL Server 2011

When SQL Server 2005 was released, we saw the introduction of structured exception handling using BEGIN TRY, BEGIN CATCH statements. This fantastic feature allowed us to trap and handle exceptions that we may encounter in the course of our code … Continue reading

Posted in SQL Server 2011 "Denali", T-SQL Code Examples | Tagged , , , | 3 Comments

Fun With SET Based Operations 2

Okay, now for a little more fun with SET based operations. This is a quick post that will show you how to combine multiple rows for 1 column, into a 1 row, 1 column, as a comma delimited list. It’s … Continue reading

Posted in T-SQL Code Examples | Tagged , | Leave a comment

Fun With Set Based Operations

Ok, maybe the title is a little misleading, perhaps fun is not quite the right word, perhaps it’s better to say ‘Something Interesting About Set Based Operations’, but it just doesn’t seem that catchy. You’ve probably worked with variables before, … Continue reading

Posted in T-SQL Code Examples | Tagged , , | Leave a comment

Get the query text for specific SPID/session

Have you ever wanted to get the query text for a SPID to see what query is or was in use? Continue reading

Posted in T-SQL Code Examples | Tagged , | Leave a comment