Explaining SQL Server Statistics

Query optimizer depends on statistics to estimate the cardinality or number of rows of a query result. In other words, it is the knowledge of how many rows are in a table, and how many of those rows satisfy the various search and join conditions, and so on. Based on this, optimizer creates the best query plan. Sometimes, tweaking the statistics helps to produce efficient query plan. In this article, we are going to explore the fundamentals of SQL Server statistics. [More]

Understanding SQL Server Execution Plan Part-1

When a query performs poorly and you fails to understand the reason behind it. You need to check the execution plan. However, reading an execution plan is like reading a new language. You need to understand the operators, their properties, data flows, meaning of icons, order of operators etc. In this article series, I am going to discuss this step by step. [More]

Dropping a Principal Who Owns a schema

That day one of my junior colleague rushed to me and sought my assistance. He failed to drop an user. It showed - "The database principal owns a schema in the database, and cannot be dropped." I took him to our office kitchen, had tea, and explained the issue. [More]

Understanding Index Fragmentation

That day, I was purchasing some items from my neighbouring grocery shop. I noticed, the shop owner was maintaining his debtors list in his ledger book. I found his ledger book started with a table of his customer list along with page numbers. Pages had transactions of individual customer. In case of a page became full, it had reference of another pages with bunch of transactions. There are some blank pages and also blank spaces in some pages. Suddenly, I realized how SQL Server manage the INDEX functionality. [More]

Random Datetime For All Rows in a Query

In my previous article, I showed you how to generate a random datetime value for column. In this article, I will discuss you how to generate random Datetime for all rows in a query. [More]