A temporary table with a hash (#) or double hash (##) is a temporary table stored in the system database tempdb. This table exists only for the duration of...
What about upgrading GROUP BY clause by use of useful commands? GROUP BY is used in a clause with aggregate operations. When it is used, aggregation happens throughout all...
Some time ago, I published an article on the RAISERROR command, which raises an exception and allows us to influence whether the script will or will not continue based...
In certain situations, it’s necessary to call an error within an SQL script and interrupt its execution. Typical scenarios include failing a data quality check or the need to...
SQL TRY CATCH command is designed to control code flow in case that error situation occurs (error handling). This construction consists of blocks. It is also possible to use...
Operator UNION ALL in SQL makes it possible to unify 2 query results and does not remove duplicities in queries. Operator returns records of both queries with no regard...
T-SQL command IF is used to control flow of code mainly in operations where we somehow influence db (DDL, DML operations) – for example procedures. You can mix it...
SQL CTE, or Common Table Expression, is essentially a temporary result set represented in the form of an expression. Once declared using the WITH clause, it can be referenced...
OVER clause can belong to commands working with so-called Window functions in SQL. These types of functions enable us to look at the data not only in their aggregated...
The order in which are the SQL clauses entered into the query are quite known. However, the order of logical query processing is different than in which we enter...
Loop is a repeated call of a part of a code with different parameters. Usually the code is bound to certain DML operation such as INSERT or UPDATE. We...
SQL Command INSERT is suitable for situations when we want to insert entries into the table. Insertion of rows can be done in multiple ways (further description below): You...
IDENTITY is a property in SQL Server that allows for the automatic numbering of records inserted into a table. It creates an automatic increment with unique values without the...