Add a Time Zone Offset to a datetime2 Value in SQL Server (T-SQL)

In SQL Server, the TODATETIMEOFFSET() function was specifically designed to return a datetimeoffset value from a datetime2 value.

Given the fact that the datetime2 data type doesn’t actually support time zone offsets, and datetimeoffset must contain the offset, the TODATETIMEOFFSET() function allows you to specify a time zone offset to use.

This article provides some examples to demonstrate.

Continue reading

How to Concatenate Strings in SQL

Most of the major RDBMSs provide several options for concatenating two or more strings.

  • There’s the CONCAT() function, which concatenates its arguments.
  • There’s also a CONCAT_WS() that allows you to specify a separator that separates the concatenated strings.
  • And there’s also a string concatenation operator, which allows us to concatenate its operands.

Below are examples of each method.

Continue reading

How to Install SQL Server on an M1 Mac (ARM64)

I previously explained how to install SQL Server on a Mac using the SQL Server for Linux Docker image.

Since then, Apple has released its M1 chip, which uses ARM architecture. This can cause a problem when trying to install SQL Server. The problem is, at the time of writing, SQL Server isn’t supported on the ARM architecture.

Fortunately, there’s an alternative.

Continue reading