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.
t-sql
How to Check the Recovery Model of a Database in Azure SQL Edge using T-SQL
In Azure SQL Edge, you can query the sys.databases catalog view to see the recovery model for each database.
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.
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.
Get the Number of Failed Login Attempts for a Login due to a Wrong Password in SQL Server (T-SQL)
In SQL Server, you can use the LOGINPROPERTY() to return information about login policy settings.
This includes being able to return data for bad password attempts, as well as the time of the last failed login attempt due to a bad password.
How to Back Up an Azure SQL Edge Database to Local Disk using T-SQL
Microsoft Azure SQL Edge’s backup capabilities are similar to those in SQL Server on Linux, and SQL Server running in containers.
Azure SQL Edge supports T-SQL, and so you can back up your SQL Edge databases by running a T-SQL statement.
In this article, I back up a SQL Edge database to the local disk in my Docker container.
How to Backup the Transaction Logs in Azure SQL Edge (T-SQL)
By default, databases created in Azure SQL Edge use the simple recovery model. This means that you can’t perform log backups on these databases.
Fortunately, you can change a database’s recovery model to full recovery mode, which will enable you to back up the logs.
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.
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.
Get the Current Login ID in SQL Server (T-SQL)
You can use the SUSER_ID() function to return the login identification number of the current user.
You can also use it to return the login ID of another user.
This is similar to returning the current login name, except here we’re returning the ID instead.