Blog Archives

Corruption Challenge 1 – how I corrupted the database

Since the corruption challenge completed yesterday, I have had several request asking how I created the corrupt database. So here is the script that I used to create the Database Corruption Challenge 1. First the initial setup. Most of this

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

T-SQL Technical Debt

Technical Debt is a programming concept that is also known as code debt. The concept of Technical Debt applies closely with Agile software development, but also applies to database development. There are many tools available to report on technical debt

Posted in Database Health, Technical Debt Tagged with: , , , , , ,

DBCC ShrinkDatabase

Being day 24 of the DBCC Command month at, today’s featured DBCC Command is DBCC SHRINKDATABASE. When I first heard about DBCC Shrink Database (many years ago), I immediately thought “what a great feature, run this every night when

Posted in DBCC Commands Tagged with: , , , , , , , , , , , , ,

T-SQL: A Simple Example Using a Cursor

For more information on cursors, also take a look at the free SQL query training provided by Steve Stedman. In SQL Server the cursor is a tool that is used to iterate over a result set, or to loop through each

Posted in SQL 2008, SQL 2012, TSQL Tagged with: , , , , , , ,

Recursive Scalar Function in T-SQL

In my Common Table Expressions presentation the topic of recursion often comes up, but for scalar functions in T-SQL, it might not be as common. This article has been written to show how a scalar function in SQL Server can

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


Here is a quick rundown on the T-SQL DATEPART function for SQL Server. DATEPART is used to pull a single part of a date/time element out as shown below. The following query uses DATEPART to extract the year from the

Posted in TSQL Tagged with: , , , , ,

Select Favorite SQL Server 2012 Articles

The following articles are a collection of my favorite SQL Server related posts over the last 6 months. 3 Steps to Work More Efficiently in SSMS. Posted 2/17/2013 Recently the 3 Steps to Work More Efficiently in SSMS article was one of

Posted in SQL 2012 Tagged with: , , , , , ,

VARCHAR diff function

Last month I posted another CTE blog entry Using a CTE to Split a String Into Rows with Line Numbers.  Since then I have used it but, but realized that what I really needed was a diff tool to compare two

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

Cannot resolve the collation conflict

One possible cause of the “Cannot resolve the collation conflict” error message is that your database collation doesn’t match the TempDB Collation. Recommendation It is recommended that the collation of your database match the collation TempDB.   It is possible

Posted in TSQL Tagged with: , ,

Using the OUTPUT Clause in TSQL for Auditing

The OUTPUT clause is often times underappreciated by the TSQL programmer.  There are many really interesting things that you can do with the OUTPUT clause, from inserting to two tables with one statement or to replace the SCOPE_IDENTITY option.  For

Posted in TSQL Tagged with: , , , ,

SQL Server Performance Tuning

Need help with SQL Server Performance Tuning, contact Steve at Stedman Solutions, LLC for help, or take a look at the performance tuning page at the blog. We can help with tuning a single query or with figuring out why your SQL Server is running slow. Free 30 minute consultation.

Newsletter Signup

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

Stedman Solutions