Fix: “BACKUP LOG cannot be performed because there is no current database backup.” in SQL Server/SQL Edge

If you’re trying to back up the transaction logs in a SQL Server or SQL Edge database, but you get an error that states BACKUP LOG cannot be performed because there is no current database backup, you’ll need to perform at least one full backup of the database before you attempt to back up the transaction logs.

Continue reading

Fix: “The statement BACKUP LOG is not allowed while the recovery model is SIMPLE” in SQL Server (and SQL Edge)

If you get an error that reads The statement BACKUP LOG is not allowed while the recovery model is SIMPLE when trying to back up a database in SQL Server or Azure SQL Edge, it’s because you’re trying to back up the transaction logs on a database that uses the simple recovery model.

To fix this, change the recovery model to either full or bulk logging.

Continue reading

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 Change the Recovery Model of a Database in Azure SQL Edge using T-SQL

By default, databases created with Azure SQL Edge use the simple recovery model. This means that you can’t perform log backups on these databases.

If you need to perform log backups on a database created with SQL Edge, you’ll need to change the recovery model of the database to either full or bulk logged.

This can be done with T-SQL with the ALTER DATABASE statement.

Continue reading

About the DATE_BUCKET() Function in Azure SQL Edge

T-SQL includes a DATE_BUCKET() function that allows you to arrange data into groups that represent fixed intervals of time. It returns the datetime value that corresponds to the start of each datetime bucket, as defined by the arguments passed to the function.

As far as I’m aware, the DATE_BUCKET() function is only available in Azure SQL Edge at the time of this writing.

Update: DATE_BUCKET() was introduced in SQL Server 2022.

Continue reading