SQL Server T-SQL Articles

SQL Server T-SQL Tuning -TVF and Scalar Functions

In the first of this series we looked at TSQL tuning for temp tables, table variables and the Union command , we now turn our attention to User Defined Functions – either Table-Valued Functions or Scalar Functions. A UDF is very convenient for centralising business logic as we can specify a set of business logic […]

SQL Server T-SQL Tuning – Temp Tables, Table Variables and Union

In this article series we will focus on the primary points of T-SQL performance tuning. In this first installment I will lopok at tuning temp tables, table variables and the Union command. Temp Tables and Table Variables Most database developers are used to breaking down code into small chunks using  temp tables or table variables  […]

Tuning your SQL Query – Generating a Proper Execution Plan.

Recently one of my developers came to and complained of slow performance on a particular query. During the investigation I noticed that the primary cause was the poor query execution plan. In this article, I will discuss the approach which I used to improve the execution plan. For demonstration purpose, I will be creating a […]

SQL Server T-SQL Performance Tuning – Views

In this installament of the TSQL Performance Tuning series we turn our attention to Views Views Used Within Joins or Where Conditions As a generic concept, an inner join with an object which has insufficient indexing will result in index scanning or perhaps a table scan which also applies for Views Impacts: • Much CPU […]

SQL Server Performance Tuning – Index Tuning

In earlier installments of this series we looked at T-SQL Performance optimizations along with different T-SQL practices, we can now turn our attention to the second part of this series which is index Tuning In looking into Views we will break the article into two sections : Basic Index Tuning using DTA (Database Tuning Advisor) […]

New T-SQL Features in SQL Server 2012

SQL Server 2012 (or Denali) CTP is now available and can be downloaded at http://www.microsoft.com/downloads/en/details.aspx?FamilyID=6a04f16f-f6be-4f92-9c92-f7e5677d91f9&displaylang=en SQL Server 2012 has several major enhancements including a new look for SSMS. SSMS is now   similar to Visual Studio   with greatly improved Intellisense support. This article we will focus on the T-SQL Enhancements in SQL Server 2011. The main […]

Whether to use UNION or OR in SQL Server Queries

Recently I came across with an article on DB2 about using Union instead of OR. So I thought of carrying out a research on SQL Server on what scenarios UNION is optimal in and which scenarios OR would be best. I will analyze this with a few scenarios using samples taken  from the AdventureWorks database […]


SQL Server has the ability to provide the information on  specific columns which  been modified by triggers, by using the COLUMNS_UPDATED function. COLUMNS_UPDATED is an in-built function of SQL server that helps to identify the columns in the table or view that were inserted or updated. COLUMNS_UPDATED returns a varbinary bit pattern showing which columns […]