Data type SQL Server

By Tan Lee Published on Feb 19, 2024  483
In SQL Server, various data types are available to store different types of data efficiently.

Here are some common data types used in SQL Server:

1. Numeric Data Types:

- INT: Integer data type for storing whole numbers.

- BIGINT: Large integer data type.

- DECIMAL/NUMERIC: Fixed-point decimal numbers.

- FLOAT/REAL: Floating-point numbers.

2. Character String Data Types:

- CHAR(n): Fixed-length character data type.

- VARCHAR(n): Variable-length character data type.

- TEXT: Variable-length character data for large text.

- NCHAR(n): Fixed-length Unicode character data.

- NVARCHAR(n): Variable-length Unicode character data.

- NTEXT: Variable-length Unicode character data for large text.

3. Date and Time Data Types:

- DATE: Date data type.

- TIME: Time data type.

- DATETIME: Date and time data type.

- DATETIME2: Date and time data type with higher precision.

- TIMESTAMP: Automatic timestamp value.

4. Binary Data Types:

- BINARY(n): Fixed-length binary data.

- VARBINARY(n): Variable-length binary data.

- IMAGE: Variable-length binary data for storing images or large binary objects.

5. Other Data Types:

- BIT: Boolean data type.

- UNIQUEIDENTIFIER: Globally unique identifier (GUID).

- XML: XML data type.

- JSON: JSON data type (available in newer versions).

These are just some of the data types available in SQL Server. Each data type serves a specific purpose and allows for efficient storage and manipulation of data within the database.