Creating a table in the SQL Server database is a basic skill. While creating it using SQL command CREATE TABLE we define: Name of the table together with database...
ISNULL and COALESCE are functions used for work with null values (NULL). Both functions return first value out of previously defined entry parameters. There are also some differences between...
Views have definitely their place in databases and data warehouses. We are talking about objects which are good to use since they do not contain data (do not take...
UPDATE Statement is used in SQL to change existing records in a table. This way, we can change one record, multiple records or all of them. Condition based on...
This mini-article is made for beginners. We will take a closer look on how to write a simple T-SQL script and I will also explain basic sql commands. We...
T-SQL TRUNCATE command deletes all records in the table. Apart from DELETE (more in article SQL DELETE) command, there is no possibility to filter which record to delete. It is...
SQL MERGE command is an advanced way of comparing data in two tables (Source and Destination). We compare records and based on match (or difference) we execute UPDATE, INSERT...
This operator can find string of text based on a certain pattern. It is most usually used in clause WHERE. But it can be applied in any part of...
T-SQL is not a language designed primarily to do something big with text strings or manipulate with them. That is the reason why we will not find many text-related...
System stored procedures are useful administrative tools. Below, you may find 10 of them which I consider as the most useful: sp_help – info on objects in database, data types...
Comments in SQL query have a simple purpose. They keep the code well-arranged for others and also explain its logic. If you mark some text as a comment it...
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...
GROUP BY clause is used to group data. In most of the cases, we talk of a situation when we need to make an aggregate operation in the table...
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...
HAVING clause is a special type of SQL command. It works in a similar way as WHERE clause and we use it to define a condition. There are important...
SQL aggregate functions AVG, COUNT, MAX, MIN, SUM are used the most. That is because we often need to add, make average or find the highest or lowest value....
SQL ranking functions enable us to rank records in the table based on values of a field or multiple fields. Clause OVER() is mandatory for the ranking functions. Ranking...
ORDER BY clause in SQL enables us to sort results of the query by specific field (column) or more columns. There are 2 sorting options: Ascending order (ASC) –...
OFFSET functions are relatively new to MS SQL Server. They are available since SQL Server 2012 version. These functions enable a user to “list” through rows of a table....
WHERE clause is used to define limit requirements for queries. We are not interested in all records in most cases of queries into tables. Only some subsets of the...