Skip to content

SQL Bits

You're here to find quick SQL recipes.

  • Home
  • Topics
    • Generic SQL
    • PostgreSQL
    • MariaDB
    • MySQL
    • Oracle
    • SQL Server
    • Db2
    • Informix
    • SQLite
  • Advertising
  • Write
  • About

Tag: level-intermediate

Non-trivial uses of LIKE in SQL

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.

Continue reading Non-trivial uses of LIKE in SQL
Published March 10, 2022
Categorized as Generic SQL Tagged 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.

Continue reading Db2: How to create an array from a query
Published December 12, 2021
Categorized as Db2 Tagged level-intermediate

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.

Continue reading SQL Server: Find users login time
Published December 2, 2021
Categorized as SQL Server Tagged level-intermediate

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.

Continue reading SQL Server: Writing an HTML encode function
Published November 28, 2021
Categorized as SQL Server Tagged level-intermediate

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.

Continue reading How to find the mode in SQL, aka MAX(COUNT(*)) not working
Published November 14, 2021
Categorized as Generic SQL Tagged level-expert, level-intermediate

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.

Continue reading SQL Server: How to count occurrences of a substring in a string
Published November 11, 2021
Categorized as SQL Server Tagged level-intermediate

Db2: How to create IDENTITY columns

Db2 supports the IDENTITY keyword to create autoincremental columns. Several options are available.

Continue reading Db2: How to create IDENTITY columns
Published November 7, 2021
Categorized as Db2 Tagged level-intermediate

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.

Continue reading PostgreSQL: Change passwords
Published October 30, 2021
Categorized as PostgreSQL Tagged level-intermediate

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.

Continue reading Creating UNSIGNED columns in SQL Server
Published October 22, 2021
Categorized as SQL Server Tagged level-intermediate

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.

Continue reading MariaDB: Rollback the transaction if a warning occurs
Published October 13, 2021
Categorized as MariaDB Tagged level-intermediate

Posts navigation

Page 1 … Page 4 Older posts
  • Twitter
  • Email
SQL Bits
Proudly sponsored by Vettabase.