JSON support in MS SQL Server
SQL Basics (SQL 4 beginners)
Approximate Count in MS SQL using APPROX_COUNT_DISTINCT
- There is a case when we want to get the unique number of non-NULL values in one table column. Before MS SQL 2019 to accomplish this task, we could use the COUNT(DISTINCT([Column_Name])) syntax. For larger tables this approach can generate noticeable performance problems. MS SQL 2019 introduced us the APPROX_COUNT_DISTINCT function that approximates the count within a 2% precision to the actual value but at a fraction of the time and with noticeable decrease of used resources (memory and CPU).
AT TIME ZONE
- MS SQL AT TIME ZONE was introduced in MS SQL version 2016 and the main purpose is to convert an inputdate to the corresponding datetimeoffset value in the target time zone.
COMPRESS AND DECOMPRESS
- MS SQL COMPRESS and DECOMPRESS are introduced into MS SQL version 2016. In this post we will read the overview of both functions, limitations and benefits. We will also test the performance compared to ROW and PAGE compression methods.
CONCAT vs CONCAT_WS
- SQL Server function CONCAT is introduced in MS SQL version 2012. Simple as that it returns a string that is the result of concatenating two or more string values. Let’s compare it with the new function CONCAT_WS which is introduced in MS SQL Server 2017.
CREATE OR ALTER
- CREATE OR ALTER is a new MS SQL Server syntax extension introduced from MS SQL Server 2016. Read more about it in this post.
- In short, introduced in MS SQL 2016, DATEDIFF_BIG is almost the same function as DATEDIFF starting from MS SQL 2008 that is commonly used already. So, let’s see how and for what is used and what are the benefits.
DROP IF EXISTS (a.k.a. DIE)
- DROP IF EXISTS is a new MS SQL Server syntax extension introduced from MS SQL Server 2016. Read more about it in this post.
Encrypt database backup step by step guide
- Sometimes you may need to protect your information from unauthorized access. Of course, it is extremely important that you regularly backup your databases. But how to protect backup files? In this article, we will explain step by step how to back up your database and how to restore it.
- Read more about MS SQL FORMATMESSAGE function introduced in MS SQL 2016. Find samples and explanations. Let's find how to use it and what has in common with the C# String.Format() method.
HASHBYTES - Hashing in MS SQL Server
- In short words, hashing is a process of generating a value or values from a string of text using a mathematical function. Let's see the usage of the MS SQL function HASHBYTES witch purpose is to hash values. MS SQL function HASHBYTES was introduced in MS SQL version 2005 supporting MD2, MD4, MD5, SHA, SHA1 hashing algorithms. From MS SQL server version 2012 additionally the SHA2_256, SHA2_512 algorithms were introduced. In this article we will discuss about hashing, what's new from SQL 2016 and see some usage examples.
Historical data with MS SQL System-Versioned (Temporal) Tables
- Before the existence of system-versioned temporal tables, tracking changes in a database table forced us to implement some custom solutions based on triggers, stored procedures etc. System-versioned temporal tables offer us the possibility to keep a full history of data changes and allowing us easy point in time analysis. Using this solution, we can easily time travel through the data and see what the exact state of the data in a point of time was.
Install MS SQL on Linux (Ubuntu)
- With basic Linux knowledge let’s try to step by step install MS SQL Server on a Linux server (Ubuntu).
Scalar UDF are (not) evil? - SQL 2019
- Sometimes using user defined functions (before SQL 2019) could lead us to performance problems. Let’s see how the usage of UDF performs in SQL 2019 and in earlier versions.
SQL Advice - COUNT(*) vs EXISTS
- If you want to check for data existence in a table (e.g. if there are invoices on a concrete date) you could use COUNT(*) or the EXISTS statement. I found various theories on the internet and even in some SQL books what is the best approach, so I decided to test this by myself (spoiler alert: the books are on the side of using EXISTS).
SQL Advice - Use constraints
- Why you should use constraints on your tables? Except the fact that you should use constraints to check your data and the integrity of them (e.g. only allow inserting of numeric value between 1 and 5 for storing vote value) you could use them also for better query executions and get some performance boost. Let’s find how.
String or binary data would be truncated
- Let’s find out how MS SQL 2019 handles the problem that generates the commonly known error “String or binary data would be truncated”.
- In this post we will learn something about MS SQL STRING_AGG function introduced in MS SQL version 2017 for string aggregation, how we did it before and test its performance compared to the old way.
- MS SQL STRING_ESCAPE introduced in MS SQL 2016 escapes special characters in texts and returns text with escaped characters.
- Let's talk about MS SQL STRING_SPLIT table-valued function introduced in MS SQL version 2016 for splitting string values by a separator. How we did it before and test its performance compared to the old way. We will also see the pros but also cons of the function.
- Read more about MS SQL TRANSLATE function introduced in MS SQL 2017. Find samples and explanations.
- TRIM is a new MS SQL Server function introduced from MS SQL Server 2017. It removes space characters from both sides (at the beginning/left and at the end/right) of the given string value. You can read more in this post.