In SQL Server, RIGHT_SHIFT()
is a bit manipulation function that returns the first argument bit-shifted right by the number of bits specified in the second argument.
The RIGHT_SHIFT()
function was introduced in SQL Server 2022.
In SQL Server, RIGHT_SHIFT()
is a bit manipulation function that returns the first argument bit-shifted right by the number of bits specified in the second argument.
The RIGHT_SHIFT()
function was introduced in SQL Server 2022.
In SQL Server, LEFT_SHIFT()
is a bit manipulation function that returns the first argument bit-shifted left by the number of bits specified in the second argument.
The LEFT_SHIFT()
function was introduced in SQL Server 2022.
SQL Server 2022 introduced the GREATEST()
function that returns the maximum value from a list of values. You may be thinking, “but there’s already a MAX()
function that returns the maximum value, so why the need for another function that does the same thing?”.
Well here’s the thing – they don’t do the same thing. They’re actually quite different functions, used in different scenarios.
If you’re wondering what the difference is between the MAX()
and GREATEST()
functions, read on to find out.
The SQL EXISTS
predicate is used to specify a test for a non-empty set. It returns TRUE
or FALSE
, depending on the outcome of the test.
When we incorporate the EXISTS
predicate operator into our SQL queries, we specify a subquery to test for the existence of rows. If there are any rows, then the subquery is TRUE
. If there are no rows, then the subquery is FALSE
.
From SQL Server 2022 we can use the JSON_PATH_EXISTS()
function to test whether a specified SQL/JSON path exists in the input JSON string.
It’s similar to the JSON_CONTAINS_PATH()
function that’s available in MySQL and MariaDB.
In SQL Server, we can use the JSON_OBJECT()
function to construct JSON object text from zero or more expressions.
The resulting object contains the key/value pairs that we provide as arguments. Providing zero expressions results in an empty object.
Continue readingIn SQL Server, the GENERATE_SERIES()
function is a relational operator that returns a series of values between a given start and stop point. These are returned in a single-column table.
Although the GENERATE_SERIES()
function only works with numeric values, we can combine it with other functions to create a series of dates.
The GENERATE_SERIES()
function was introduced in SQL Server 2022 (16.x) and requires the compatibility level to be at least 160.
The release of SQL Server 2022 came with the introduction of the DATE_BUCKET()
function.
The DATE_BUCKET()
function allows us to arrange data into groups that represent fixed intervals of time. It returns the date/time value that corresponds to the start of each date/time bucket, as defined by the arguments passed to the function.
In SQL NULL
is a special value, or mark, that is used to indicate the absence of any data value. And this is the case with SQL Server.
But SQL Server also has a special use of NULL
in certain cases.
In SQL Server, we can use the DATETRUNC()
function to truncate a date/time value to a specified precision.
For example, we could use it to truncate a date value like 2024-10-25 to 2024-01-01, or a time value like 10:35:12 to 10:00:00.
The DATETRUNC()
function was introduced in SQL Server 2022 (16.x).