What is @@TEXTSIZE in SQL Server?

In SQL Server, the @@TEXTSIZE configuration function returns the current value of the TEXTSIZE option.

No argument is required. You can simply use it in a SELECT statement to return the current TEXTSIZE value.

The TEXTSIZE value specifies the size of varchar(max), nvarchar(max), varbinary(max), text, ntext, and image data returned by a SELECT statement. This value can be set using SET TEXTSIZE.

Continue reading

What is “rowversion” in SQL Server?

In SQL Server, rowversion is a data type that exposes automatically generated, unique binary numbers within a database. It allows you to version-stamp table rows with a unique value. This helps maintain the integrity of the database when multiple users are updating rows at the same time.

Each SQL Server database has a a counter that is incremented for each insert or update operation that is performed on a table that contains a column with the rowversion data type (or its timestamp synonym, which is flagged for deprecation).

If a table contains a rowversion (or timestamp) column, any time a row is inserted or updated, the value of the rowversion column is set to the current rowversion value. This is true, even when an UPDATE statement doesn’t result in any changes to the data.

Continue reading

What is a Format String in SQL Server?

In SQL Server, the FORMAT() function enables you to format date/time and number values as a formatted string by passing in a “format string” as the second argument (the first argument is the value that’s being formatted).

Here’s an example of this function in action:

FORMAT(@date, 'dd/MM/yyyy');

In this case the format string is dd/MM/yyyy.

This particular format string specifies that the @date value should be formatted with a two-digit day, two-digit month, and a four-digit year, in that order, and with forward slashes as the separators.

This would result in something like this:

21/05/2019

Continue reading

What is the Year 2038 Problem?

The Year 2038 problem (also referred to as the Y2K38 bug) refers to a problem that some computer systems might encounter when dealing with times past 2038-01-19 03:14:07.

Many computer systems, such as Unix and Unix-based systems, don’t calculate time using the Gregorian calendar. They calculate time as the number of seconds since 1 January 1970. Therefore, in these systems, time is represented as a big number (i.e. the number of seconds passed since 1970-01-01 00:00:00). This is typically referred to as Epoch time, Unix time, Unix Epoch time, or POSIX time. As I write this, Unix time is 1560913841. And as I write this next line, Unix time has incremented to 1560913879.

Continue reading

What is Azure Data Studio?

Microsoft Azure Data Studio is a free, cross-platform tool that can be used to manage SQL Server, Azure SQL Database, and Azure SQL Data Warehouse.

Azure Data Studio was formerly called SQL Operations Studio (while it was in preview release), and it was renamed to Azure Data Studio once it was moved to general availability (GA) on September 24, 2018.

Continue reading

JSON_ARRAY_APPEND() – Append Values to a JSON Array in MySQL

When using JSON documents with MySQL, we can use the JSON_ARRAY_APPEND() function to append new values to an array.

The way it works is, you provide the JSON document as the first argument, then follow that up with the path to append to, followed by the value to append.

In MySQL 5.7, this function was called JSON_APPEND() but that name is no longer supported.

Continue reading

What is T-SQL?

Transact-SQL, often abbreviated to T-SQL or even TSQL, is Microsoft’s and Sybase’s proprietary extension to SQL. Transact-SQL expands on the SQL standard to include extra features that aren’t included in the SQL standard.

Here’s an example of a simple T-SQL statement:

CREATE DATABASE Movies;

This is as simple as a T-SQL example could get. This creates a new database called Movies.

However, T-SQL provides for other options to be included in this statement, such as where the database files should be located, the size of those files, what their maximum size should be, and more.

Continue reading

What is LENGTH() in MySQL?

One of the many functions in MySQL is the LENGTH() function, which returns the length of a string, measured in bytes.

Example:

SELECT LENGTH('Lit');

Result:

+---------------+
| LENGTH('Lit') |
+---------------+
|             3 |
+---------------+

This is a simple example and the result is the same as if we’d used the CHAR_LENGTH() function. However, the LENGTH() function can return different results, depending on the data type.
Continue reading