Blog Archives

Deleting from a CTE with an EXISTS statement

During my 24 Hours of Pass presentation on Advanced CTE’s today I was asked the question about deleting from a CTE when it uses an EXISTS statement that queries another table. I figured I would create quick blog post to show

Posted in CTE Tagged with: , , ,

Database Corruption Challenge Week 7 – Alternate Solution

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

Posted in Corruption Tagged with: , , , , , , ,

Week 5 – Alternate Solution

Here is how I solved Week 5 of the Database Corruption Challenge. The following steps were tested and confirmed working on SQL Server 2008R2, SQL Server 2012, and SQL Server 2014.   To oversimplify, here are the steps: Restore the

Posted in Uncategorized Tagged with: , , , , , ,

Corruption Challenge Week 4 – The Winning Solution

Congratulations to Randolph West who won the corruption challenge this week with the following solution which restored all of the data. First he restored the database to get started. Note some of his code and comments have been reformatted to

Posted in Corruption Tagged with: , , , , , , ,

Using the TSQL CHOOSE Function

Here is a short video tutorial that shows how to use the CHOOSE function in T-SQL on SQL Server 2012, SQL Server 2014 or Newer. This was originally part of my free SQL query training for the 70-461 certification exam. Here

Posted in 70-461 Training Tagged with: , , , , , , ,

Using the TSQL COALESCE Function

Here is a short video tutorial that shows how to use the COALESCE function in T-SQL on SQL Server. This was originally part of my free SQL query training for the 70-461 certification exam. Here is the first sample code

Posted in 70-461 Training Tagged with: , , , , , ,

T-SQL: A Listing Databases Example Using a Cursor

In SQL Server the cursor is a tool that is used to iterate over a result set, or to loop through each row of a result set one row at a time. It may not be the best way to

Posted in TSQL Tagged with: , , , , , , , ,

SQL Sunday Fun – Word Search with New T-SQL 2012 Functionality

    Click on the grid to enlarge, then print it. Find the following words in the grid up, down, left, right, horizontal, vertical, and diagonal. ROWS  RANGE  PRECEDING  FOLLOWING  UNBOUNDED  IIF  CHOOSE  OFFSET  FETCH  FORMAT  CONCAT  SEQUENCE  PARSE  TRYPARSE 

Posted in SQL Sunday, TSQL Tagged with: , , , , , , ,

CTE Data Paging

Day 14 of Common Table Expression Month (June) at SteveStedman.com, today we will be taking a look at data paging with CTE’s and how it compares to the offset and fetch in T-SQL 2012. Now on to CTE Data Paging. These queries

Posted in CTE, CTE Book Tagged with: , , , , , , , ,

Multiple CTEs in a Query

Day 10 of Common Table Expression Month (June) at SteveStedman.com, today we will be taking a look at how to use multiple CTEs in a query. These queries will be using that database that was set up in a previous posting

Posted in CTE, CTE Book Tagged with: , , , , , ,

Newsletter Signup

Stay informed of Database Corruption Challenge events, and other things happening at SteveStedman.com with my newsletter.
Newsletter signup form.

Stedman Solutions

StedmanSolutionsRemoteSkilledDBA