Detect Whether a Value Contains at Least One Numerical Digit in SQL

Sometimes you might need to search a database table for only those rows that contain at least one number in a given column.

Technically, numbers can be represented by words and other symbols, but here “number” means “numerical digit”.

Below are examples of how to find rows that contain at least one number in various SQL based DBMSs.

Continue reading

How to Check a Column’s Data Type in SQL

In SQL, the columns information schema view, which returns information about columns, is an ISO standard view that is supported by most of the major RDBMSs. You can use this view to get information about a column’s data type.

Most of the major RDBMs also provide other methods for getting column information.

Here are examples of getting the data type of a column in various SQL databases.

Continue reading

How to Format Numbers with Commas in SQL

Most of the major RDBMSs have functions that enable us to format numbers with commas as either the group separator, or the decimal separator.

Some RDBMSs also output certain numeric data types with commas in the relevant place.

Below are examples of formatting numbers with commas in some of the more popular DBMSs.

Continue reading