SQL CHAR et VARCHAR


Exemple

Types de données de chaîne de longueur fixe ou variable.

Syntaxe:

CHAR [ ( n_chars ) ]
VARCHAR [ ( n_chars ) ]

Exemples:

SELECT CAST('ABC' AS CHAR(10)) -- 'ABC       ' (padded with spaces on the right)
SELECT CAST('ABC' AS VARCHAR(10)) -- 'ABC' (no padding due to variable character)
SELECT CAST('ABCDEFGHIJKLMNOPQRSTUVWXYZ' AS CHAR(10))  -- 'ABCDEFGHIJ' (truncated to 10 characters)