The alternate solution to the Database Corruption Challenge this week was created by Patrick Flynn. This solution is the only solution to successfully recover all the data without using any of the backups. If the challenge had been structured differently and all you had was just the database files and no backups, this solution would work just fine. As you …

Database Corruption Challenge Week 7 – Alternate Solution Read more »

Here is a quick video tutorial on how to use the T-SQL CASE function on SQL Server 2012, SQL Server 2014 0r newer. This was originally part of my free SQL query training for the 70-461 certification exam. Here is the sample or demo code from the video tutorial. More Info: Additional Training on my YouTube Channel Free SQL Query Training …

Using the TSQL CASE Statement Read more »

SQL Server 2012 introduces the IIF statement. It is very similar to the IIF statement in MS Access. I have extracted the IIF part of my presentation on Whats new in SQL Server 2012, and turned it into a video with a demo of how to use the IIF statement. The IIF statement is a quick shortcut to simple CASE …

SQL Server 2012 IIF Statement Read more »

I had so much fun at SQL Saturday in Vancouver BC last year, I have decided to go again. The sessions submitted are: The “Run Faster” Switch The NO_LOCK hint is often believed to be the “Run Faster” switch, but in reality can cause some very inconsistent results.   Explore alternatives to the NO_LOCK hint to get your queries to run …

Sessions submitted to SQL Saturday Vancouver BC Read more »

In SQL Server 2012 there is a new function called CHOOSE that takes in an offset, and a list of options.  Choose is a function that returns the item at a specific index. Syntax: —CHOOSE(index, val_1, val_2, val_3, …) —If the index is greater than the number of values or less than 1 it returns NULL —Easier than using a …

TSQL 2012 CHOOSE Function Read more »

For years I have heard the question of how can I do an IIF in TSQL?  Honestly I never thought it would be that useful since the CASE statement is easy enough to use, but after seeing it in TSQL 2012, I can safely say I like it. The answer used to be, just use the CASE statement, and the …

IIF in TRANSACT SQL on SQL SERVER 2012 Read more »