CHAR (TSQL Datatype)

Is a fixed-length string datatype, with precision being the character length.


CHAR [( precision )]


The char datatype is very much the same as varchar, with the following differences:

The storage size of a char data is not affected by the value of precision. Only the actual size of the data consumes memory or disk space. The padding blanks don’t consume disk space.

There is no reason to use the char datatype in real life. It is better to use varchar instead.


DECLARE @a CHAR(10) = 'The';
DECLARE @b CHAR(10) = 'Little';
DECLARE @c CHAR(10) = 'Mermaid';

PRINT @a + @b + @c + '!';

The result is:

The       Little    Mermaid   !
RSQL, a simple alternative to Microsoft SQL Server