Finding users who never logins is not trivial in SQL Server. But we can do it by creating a logon trigger.
Sometimes we need to extract a text from the database to show it in a web page. The text should be showed as is, including any HTML tags and special characters. Normally the encoding is done by a web application, but there are cases when an SQL string is expected to return HTML encoded texts.
Sometimes you want to count all occurrences of a substring into a bigger string. For example, you may want to count all occurrences of a name in a text. This can be done, but it’s not straight-forward because SQL Server doesn’t have a specific function to do it.
There are several ways to concatenate strings in SQL, and they mainly differ in how they handle
Some DBMSs, like MariaDB and MySQL, allow to create
UNSIGNED columns. SQL Server doesn’t support unsigned integers. Let’s see what we can do instead.
SQL Server allows to handle errors with
TRY ... CATCH blocks, and provides several statements to get information about the error that is being handled.
Transact-SQL provides facilities to raise errors and warnings, as well as handling them. Here’s an introduction to this subject.
SQL Server has at least three functions to create checksums or hashes:
HASHBYTES(). Here we discuss what differences exist between them, and how to choose the proper function for a specific use case.
Most DBMSs allow to read and write comments about tables, columns and other database objects. SQL Server has a more complex feature called Extended Properties.
Sometimes we want to send an email when something suspicious happens in a database. SQL Server is able to natively send emails.