In Azure SQL Edge, you can query the sys.databases
catalog view to see the recovery model for each database.
Category: DBMS
Database Management Systems
Concatenate a String and a Number in PostgreSQL
PostgreSQL provides us with the following ways to concatenate strings and numbers:
- The
CONCAT()
function, which concatenates its arguments. - The pipe concatenation operator (
||
), which concatenates its operands.
Examples of each below.
Continue readingFix: “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 readingRPAD() Function in PostgreSQL
In PostgreSQL, RPAD()
is a function that enables us to add padding to the right part of a string.
LPAD() Function in PostgreSQL
In PostgreSQL, LPAD()
is a function that enables us to add padding to the left part of a string.
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 readingHow 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.
Continue readingHow 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 readingGet 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.
Continue readingFormat Numbers with Commas in PostgreSQL
In PostgreSQL, we can use the TO_CHAR()
function to format numbers in a given format. This includes formatting numbers with commas in the relevant location.
PostgreSQL also has a money
data type, which outputs the value using the current locale. This can include commas in the appropriate place, based on the locale being used.