Programming with Transact-SQL 2 day remote one on one training course - £450 plus VAT

Please note:

Due to the current coronovirus situation this course is currently only available as a live remote one on one course.

Once things are back to normal we will be running public dates in London, Manchester, Sheffield, Leeds, Nottingham and Birmingham, as well as in-person one on one courses and private (closed) courses.

Click here to register your interest in this course and we will keep you informed when any new dates are added.


Transact-SQL (or T-SQL) is Microsoft’s proprietary extension to SQL. This Transact-SQL programming training course will introduce you to the programming features of the language, using Microsoft SQL Server. With prior knowledge of SQL assumed, this course looks at the procedural programming language capabilities of T-SQL, such as local variables, flow control constructs, error handling and built-in functions. You will learn how to write your own functions to be used in SQL Server just in the way you use built in functions such as UPPER and GETDATE. You will also learn to write procedures, allowing you to execute any number of commands in a single database call. You'll write triggers, which automatically fire in response to a predefined database event - for example allowing you to automatically archive changed or deleted records. You'll find out how to get information from the database, such as whether there is an existing open transaction. All in all your capacity to work with SQL Server will massively increase over just using plain old SQL


2 days


£450 plus VAT (£540 inc VAT) for our remote live one on one course, accessed over the internet - click here for details


We can arrange dates to suit you - please contact us for further details or to book this course.


A working level of basic SQL (SELECT, INSERT, UPDATE and DELETE statements) is assumed. Delegates without this experience should consider the Introduction to SQL course.

Detailed course contents

Introducing Transact-SQL

  • What is Transact-SQL?
  • Procedural Programming Language
  • Programme structures
  • What does T-SQL look like?
  • Statement blocks
  • Comments
  • Adding comments


  • What are variables?
  • Declaring a variable
  • Variable names
  • Available data types
  • The scope of a variable
  • Setting a variable with SET
  • Initialising a variable
  • New operators in SQL Server 2008
  • Displaying the values of variables
  • Setting variables from queries
  • Assigning values in the UPDATE Statement

Table variables

  • Table variables
  • Table variable rules

Conditional logic

  • Conditions: IF
  • Conditions: ELSE
  • Conditions: Nested IF
  • Conditions
  • Note on declaring variables

Loops and other control-of-flow mechanisms

  • Loops
  • The WHILE statement
  • GOTO

Processing records with cursors

  • Cursors
  • Using a cursor
  • Declaring a cursor
  • Local and global cursors
  • Opening a cursor and fetching a record
  • Check if a row was returned
  • Using @@FETCH_STATUS
  • Closing and deallocating a cursor
  • Cursor variables

More cursor options

  • More on the FETCH statement
  • DECLARE CURSOR options
  • Restrictions on cursor options

Handling errors

  • Error handling in SQL Server
  • The @@ERROR global function
  • Working with @@ERROR
  • The CATCH block
  • More error functions
  • Nested TRY..CATCH blocks

Stored procedures

  • What are stored procedures?
  • Advantages of stored procedures
  • What is/is not allowed?
  • Creating stored procedures
  • Stored procedure names
  • Executing stored procedures
  • Using a result set in an INSERT statement
  • Parameters
  • Executing a procedure with parameters
  • Procedures return a value
  • Setting the return value of a procedure
  • Output parameters
  • Viewing the source code of a stored procedure
  • More procedure DDL

User Defined Functions

  • What are UDFs?
  • Creating UDFs
  • Returning a value from a function
  • Calling a scalar function
  • Table-Valued Functions
  • Calling table valued functions
  • Inline table valued functions
  • Multistatement table valued functions
  • More UDF DDL


  • SQL Server schemas
  • Creating a schema
  • Referencing a schema’s objects


  • What are triggers?
  • Uses of Triggers
  • Types of trigger
  • What can you do in trigger code?
  • DML triggers
  • DML trigger syntax
  • The inserted and deleted tables
  • The UPDATE()function
  • INSTEAD OF triggers
  • INSTEAD OF trigger rules
  • View Triggers
  • Notes on DML triggers
  • DDL triggers
  • Creating DDL triggers
  • Notes on DDL triggers
  • The EVENTDATA() Function
  • XML returned by EVENTDATA()
  • EVENTDATA() schema definition
  • Logon triggers
  • Finding information on triggers
  • Changing a trigger definition
  • Disabling, enabling and dropping triggers
  • More trigger DDL

Global functions

  • Global Functions

Dynamic SQL

  • What is dynamic SQL?
  • Dynamic SQL example
  • Guard against SQL injection


  • What are the course times?
    • Most course days run from 9.30am to around 4pm, however as we are currently only offering one on one remote courses during the current crisis, we can be quite flexible if you would like to do different hours.

  • Do I need anything?
    • For our live remote one on one courses you only need a computer with the Chrome browser, and speakers or headphones to hear the instructor. When it comes time to do an exercises you can either connect to our computer to do them, or do them on your own computer. We will advise for your specific course what software you would need to do them on your own computer but don't worry, you can connect to ours if you prefer.

  • How can I pay?
    • Once you have booked you will receive a confirmation email, and shortly after that, an invoice. For online courses payment is required before the start of the course. Payment can be made by bank transfer (BACS etc), cheque or card.

Other courses