Char type keeps the empty spaces : Char « Data Types « SQL Server / T-SQL Tutorial






16> --SET ANSI_PADDING OFF
17>
18> --DROP TABLE checkpad
19> --GO
20>
21> CREATE TABLE checkpad
22> (
23> rowid        smallint       NOT NULL PRIMARY KEY,
24> c10not       char(10)       NOT NULL,
25> c10nul       char(10)       NULL,
26> v10not       varchar(10)    NOT NULL,
27> v10nul       varchar(10)    NULL
28> )
29> GO
1> -- Row 1 has names with no trailing blanks
2> INSERT checkpad VALUES (1, 'John', 'John', 'John', 'John')
3>
4> -- Row 2 has each name inserted with three trailing blanks
5> INSERT checkpad VALUES
6>     (2, 'John   ', 'John   ', 'John   ', 'John   ')
7>
8> -- Row 3 has each name inserted with a full six trailing blanks
9> INSERT checkpad VALUES
10>     (3, 'John      ', 'John      ', 'John      ', 'John      ')
11>
12> -- Row 4 has each name inserted with seven trailing blanks (too many)
13> INSERT checkpad VALUES
14>     (4, 'John       ', 'John       ', 'John       ', 'John       ')
15> GO

(1 rows affected)

(1 rows affected)

(1 rows affected)

(1 rows affected)
1>
2> drop table checkpad
3> GO








5.4.Char
5.4.1.CHAR type column
5.4.2.Char type keeps the empty spaces
5.4.3.Compare char type data in upper case
5.4.4.Combine char and varchar type data with '+'