How to Specify the Data Type when Creating a Sequence in SQL Server

When creating a sequence object in SQL Server, the default data type is bigint. However, we can change this so that the sequence uses a data type of our choosing, as long as it’s an integer type (see below for accepted data types).

We can set the data type of a sequence by using the AS argument when defining the sequence.

Continue reading

Signed vs Unsigned Integers

The integer data type is probably one of the more common data types when working with database management systems (and with computing in general). The integer is a numeric data type that allows us to store certain kinds of numbers.

More specifically, an integer is the number zero (0), a positive natural number (e.g. 1, 2, 3, …) or a negative integer with a minus sign (e.g. −1, −2, −3, …). Integers contain no decimal or fractional part.

However, many computing environments distinguish between signed integers and unsigned integers.

Let’s take a look at the difference between signed integers and unsigned integers.

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