String Replacement Puzzle

Courtesy of SQL Server Pro. You can find the original article here.

My dad, Gabriel Ben-Gan, passed away recently. He loved numbers, logic and puzzles, and used to solve problems in his own unique way. This article is about a puzzle that incorporates the above ingredients. Dad, this one’s for you, and is in your memory.

(more…)

Wait stats information to Synchronous Bucketizer Target in Denali CTP1 with Extended Events

Following the article yesterday  (Know Where Your Query Spends Its Time), here is the code to send the wait stats information to a synchronous bucketizer; the obvious pros are that the structure is in memory, and you don’t need to stop the session to process the data; the cons are that you cannot reset the data read (unless you re-create the session); the other big con is that you cannot sum values in the columns (in the case of the wait_stats time is important). (more…)

TSQL: Automatically create Grant Execute Script for Stored Procedures

One of my favorite features in TSQL is the INFORMATION_SCHEMA views. They give you access to all sorts of information about SQL server.I frequently have a problem where i need to grant execute to a bunch of stored procedures to a particular user. On a large project, thats quite a bit of work. So i created this little query that will automatically generate the grant execute statements. Just run it, copy the output into a query window and hit F5.

 (more…)

Skewness and Kurtosis Part 1 – T-SQL Solution

In one of my previous blogs I explained basic descriptive statistics procedures. When you prepare the data for Data Mining, there is never enough of over viewing and checking the data with statistical methods. Therefore, it would be nice to have more of them available in SQL Server. Very useful measures are the 3rd and the 4th population moments- Skewness and Kurtosis.

(more…)

Skewness and Kurtosis Part 4 – Correction of Part 3 Solution

Seems like this is quite interesting topic, I have another extremely valuable comment. Joe Celko – I really don’t think his name needs any introduction hereJ – sent me another suggestion for an improvement of Steve’s version – use the standard POWER() function to return the Age column to a specific power instead of calculating the value manually.

(more…)

Graphs, Trees, Hierarchies and Itzik

As being the guest author on Itzik Ben Gan’s Inside MS SQL Server 2005: T-SQL Querying book, this blog might seem boasting to you. However, I did not write anything in the chapter 9 – Graphs, Trees, Hierarchies and Recursive Queries, and I am talking about this chapter. In a single day, I used the following solutions from the chapter:

(more…)