In Azure SQL Edge, you can query the sys.databases catalog view to see the recovery model for each database.
Relational
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.
How to Format Numbers in MariaDB
MariaDB has the FORMAT() function, which formats a number based on the given format string.
It returns the number as a formatted string, with thousands and decimal separators in the appropriate position and rounds the result to the specified decimal position.
You can optionally specify a locale value to format numbers to the pattern appropriate for the given region.
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.
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 Get the Day, Month, and Year from a Date in SQL
Most of the major RDBMSs have functions that enable us to extract the day, month, and year from datetime values.
Some RDBMSs provide multiple ways to do this, and others are more limited. Below are examples of extracting the day, month, and year from date values in some of the most popular RDBMSs.
FORMAT() Examples in MySQL
In MySQL, the FORMAT() function returns a number formatted to a specified number of decimal places.
It includes group separators and a decimal separator where applicable.
How to Format Numbers with Commas in SQL Server
SQL Server provides us with a quick and easy way to format numbers with commas inserted at the relevant place. For example, 1234.56 can become 1,234.56. Or it can become 1.234,56, if that’s the locale that you’re using.