The LIKE
operator is generally well-known. Most SQL users know how to find columns that contain a string, start with a string, or end with a string. But some of them, especially beginners, may not find obvious some other interesting uses of LIKE
.
Tag: level-intermediate
Db2: How to create an array from a query
Db2 ordinary arrays can be constructed and populated from an SQL query. Let’s see how to do it.
SQL Server: Find users login time
Finding users who never logins is not trivial in SQL Server. But we can do it by creating a logon trigger.
SQL Server: Writing an HTML encode function
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.
How to find the mode in SQL, aka MAX(COUNT(*)) not working
In statistics, the mode is the function that returns the element that appear most often in a series. This is what people try to achieve when they run MAX(COUNT(*))… and they find out that it doesn’t work. Let’s see how to obtain the mode in SQL.
SQL Server: How to count occurrences of a substring in a string
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.
Db2: How to create IDENTITY columns
Db2 supports the IDENTITY
keyword to create autoincremental columns. Several options are available.
PostgreSQL: Change passwords
Let’s see how to change a user’s password or your own password in PostgreSQL. We’ll also discuss how to avoid sending the password in clear over a network.
Creating UNSIGNED columns in SQL Server
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.
MariaDB: Rollback the transaction if a warning occurs
In MariaDB most errors cause the current transaction to rollback, but warnings don’t. This article shows how to rollback when a warning happens.