icon icon

SQL – using the advanced options for functions, procedures and variables

icon

Training process

Training needs analysis

If you have specific requirements regarding the training programme, we will carry out a training needs analysis for you. This will guide us on which aspects of the programme should receive greater emphasis, so that the training programme meets your specific needs.

What will you gain?

icon

Precise querying - You will learn to write advanced SELECT queries with WHERE, GROUP BY, HAVING, and ORDER BY, so you can pull exactly the data you need from a database on your own.

icon

Secure dynamic SQL - You will work with dynamic SQL and practical ways to reduce SQL Injection risk, so you can build flexible queries and procedures without exposing applications to common security flaws.

icon

Efficient subqueries - You will practice nested and correlated subqueries as well as EXISTS, which will help you create cleaner and more accurate solutions when simple JOINs are not enough.

icon

Functions and procedures - You will understand when to use a stored procedure and when a scalar or table-valued function is the better choice, making your SQL logic easier to organize and reuse.

icon

Better data type choices - You will understand the differences between numeric, text, date, and XML types, helping you design tables more confidently and avoid conversion, performance, and data quality issues.

icon

SQL flow control - You will master IF statements and WHILE or FOR loops, allowing you to build more advanced administrative and data-processing scripts without moving all logic into the application layer.

icon

Transaction control - You will learn to use transactions in line with ACID principles and handle errors properly, so you can run multi-step operations safely without leaving data in an inconsistent state.

icon

Automation with triggers - You will learn how DML and DDL triggers work, so you can automate reactions to data and schema changes, such as validation, auditing, or blocking unwanted operations.

Training programme

1. Detailed discussion of SQL queries

Advanced SQL work combines data retrieval, modification, and controlled transformation of result sets. The material covers SELECT-based queries, INSERT, UPDATE, DELETE, views, dynamic SQL with SQL Injection prevention, table transformations, and cursor attributes.

  • selection queries (SELECT, FROM, WHERE, GROUP BY, HAVING, ORDER BY),
  • data modification queries (INTO, INSERT INTO, UPDATE, DELETE),
  • table transformations,
  • preparing views (CREATE VIEW),
  • dynamic SQL and counteracting SQL Injection,
  • cursor attributes.

2. Analysis of the application of subqueries in SQL

Subqueries allow a query to depend on results produced at another level of processing. The section explains nested and correlated subqueries, then shows how the EXISTS operator is used to express conditional checks efficiently in SQL.

  • nested subqueries,
  • correlated subqueries,
  • EXISTS operator.

3. Understanding the concept of variables in SQL

Using variables makes SQL scripts easier to parameterize and organize. The content covers declaring table-valued variables with DECLARE and addresses creating and modifying scalar functions where variable handling supports more controlled database logic.

  • creating and modifying scalar functions,
  • table-valued (DECLARE).

4. Detailed overview of data types in relational databases

Data types determine storage rules, conversions, and the behavior of database operations. This section reviews numeric, text, date and time, XML, and selected specialized types, with attention to how type choice influences SQL design.

  • numeric (tinyint, smallint, int, bigint),
  • text (char, varchar, nchar, ntext, nvarchar),
  • date and time (datetime, smalldatetime),
  • XML (Extensible Markup Language),
  • other (e.g. hierarchyid, cursor).

5. Discussion of control statements

Controlling execution flow is essential when SQL logic must react to conditions or repeat actions. Participants work with IF statements and loop constructs such as LOOP, WHILE, and FOR to build scripts that handle branching and iteration.

  • conditional statement IF,
  • loops (LOOP, WHILE, FOR).

6. Characteristics of tables in relational databases

Temporary and global tables serve different purposes when processing intermediate data in relational databases. The section explains how these table types behave, when their scope matters, and how they support session-level or broader shared operations.

  • temporary,
  • global.

7. Analysis of differences between stored procedures and functions in SQL

Choosing between a stored procedure and a function affects how database logic is structured and executed. The comparison focuses on their roles, typical usage patterns, and practical differences relevant to query design and server-side programming.

8. Discussion of stored procedures

Stored procedures support repeatable database operations and centralize business logic on the server side. This part explains where procedures are used, how their general structure is organized, and how to create them correctly in SQL.

  • application,
  • general structure of a stored procedure in SQL,
  • creating a procedure.

9. Presentation of functions in SQL

SQL functions are covered from two angles: built-in operations and custom definitions. The material includes scalar functions for date, time, text, logical processing, and conversion, then moves to table-valued functions, grouping, ordering, and user-defined solutions.

  • scalar:
    • date and time,
    • logical,
    • text,
    • conversion,
  • table:
    • simple (inline table UDF),
    • complex (multi-statement table valued functions),
  • grouping and ordering data,
  • user-defined.

10. Explanation of the role of transactions in SQL

Reliable data processing depends on proper transaction control. Participants examine ACID principles, work through implementation examples, and learn how error handling affects COMMIT and rollback logic in practical SQL operations.

  • theoretical basis (ACID principle),
  • implementation examples,
  • error handling.

11. Discussion of triggers as automation tools in SQL

Triggers in SQL are presented as automation mechanisms reacting to data and schema changes. The section covers DML triggers for INSERT, UPDATE, and DELETE operations, as well as DDL triggers tied to CREATE, ALTER, and DROP statements.

  • DML (INSERT, UPDATE, DELETE),
  • DDL (CREATE, ALTER, DROP).

What are the prerequisites for participating in the training?

icon

SQL basics - You should be comfortable with simple SELECT queries, data filtering, and basic JOINs, so during the course you can focus on advanced topics instead of core syntax.

icon

Working with tables - You should understand tables, rows, columns, and keys, and be able to perform simple INSERT, UPDATE, and DELETE operations in a relational database.

icon

Relational database concepts - You should know basic relational database concepts such as relationships, join conditions, and common data type usage, so you can follow the course examples with ease.

icon

Hands-on experience - It is recommended that you have already worked in a database environment and run SQL queries, because this course builds practical skills rather than starting from zero.