Pr.Pg Next Pg

About T-SQL tutorials

SQL:- Structured Query Language

  • (SQL) Structured Query Language (SQL) was originally developed by IBM (International Business Machine).

  • It was developed to support the new relational data model in the early 1970s.

  • Later SQL was widely adopted in the Industry.

  • It also became the standard of the ANSI (American National Standards Institute) and of the ISO (International Organization for Standardization) in the 1980s.


T-SQL: Transact SQL

  • Now T-SQL is Microsoft’s implementation of the Industry standard Query Language for MS-SQL Sever.

  • T-SQL supports partly or full SQL Standard because the ANSI standard has gone through several revisions including SQL-89 and SQL-92.

  • MS SQL Server 2012 also implements features from later standards such as ANSI SQL-2008.

  • T-SQL is query language for SQL Server 2012.


Vendor Specific SQL

Many vendors have extended the language to include SQL Server –specific features and functions as follows.

1)     Microsoft’s Implementation as T-SQL in MS SQL Server,

2)     IBM Implements SQL as SQL PL,

3)     Oracle Implements SQL as PL/SQL and

4)     Sybase maintains its own implementation of T-SQL.


  • One thing we have to state while working with T-SQL is that T-SQL is set- based and declarative language not procedural language.

  • When we write a query to retrieve data from SQL Server we describe data we wish to display. We do not tell SQL Server exactly how to retrieve it. Instead of providing a procedural list of steps to take you provide the attributes of the data we seek.

  • For example if we want to retrieve a list of customers who are located in New York, a procedural method might look like this as follow:

1) Open a cursor to customer rows one at a time

2) Fetch the first cursor record.

3) Examine first row.

4) If the city is New York return the row.

5) Move to next row.

6) If the city is New York return the row.

7) Fetch the next record.

8) (Repeat step no 4 and 5 until it reach at the end of the table).


  • Our procedure code must not only contain the logic to select the data that meets our needs but we must also determine and execute a well-performing path through the data.

  • With set-base and declarative language such as T-SQL we will have to provide the attributes and values that describe the set we wish to retrieve such as in the following pseudo-code:

  • Display all customers whose city is New York.

  • The optimal path to access the data and return a matching set is determined by the SQL Server 2012 database engine. Our role is to learn to write efficient and accurate T-SQL code in order to properly describe the set we wish to retrieve.

  • This course has been designed to help you bridge the gap between procedural and set-based declarative T-SQL. If we have background in other programming environments (especially in procedure language) adopting a new mindset may present a challenge


Pr.Pg border                                              Next Pg