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

Tagged with: , , , , , , , ,

Executing a TSQL batch multiple times using GO

Using the GO commend in TSQL to run a batch of code multiple times is something that I commonly do in demo’s and training’s.  What amazes me is how many people after the training will tell me that they didn’t know

Tagged with: , , , , , , ,

Introduction to Recursive CTEs

Day 7 of Common Table Expression Month (June) at SteveStedman.com, today we will be taking a look at the introduction to recursive CTEs. These queries will be using that database that was set up in a previous posting on the CTE_DEMO

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

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

Tagged with: , , , , , , , , ,


SQL Server 2012 adds a new function called DateFromParts.  This new function simplifies the creating of a DATE type in TSQL over the older ways of doing it. The information here has been extracted from my SQL Saturday presentation on Whats New in

Tagged with: , , , , , , , ,

Beta 3 is Now Available.

One big new feature in Beta 3 of the Database Health Reports, the historic monitoring. The way that the historic monitoring works is that it continuously monitors your SQL Server database and logs the details around queries that are causing

Tagged with: , , , , , , ,

TSQL Pivot Table

TSQL Pivot Table?  Whats that? Here is a quick sample of how to implement a pivot table in TSQL for SQL Server. The example below creates a database called pivot, you probably already have your own database to work in.

Tagged with: , , , ,

TSQL Analytic Functions LEAD and LAG

SQL Server 2012 introduces 8 new analytic functions. This post will cover 2 of them LEAD and LAG, which can be used to reference a value in the row before or the row after the current row. If you have

Tagged with: , , , , , , ,

Big One Time Use Queries – Revisited

Just the same query that I posted months ago, but this time it is wrapped in a stored proc.  I use this one often enough that it is easier to just call the stored proc. Download the FindOneTimeUseQueries source code. TSQL example:

Tagged with: , , , ,