TSQL - To CHAR or not to CHAR

Don't use VARCHAR for columns that only need 1 or 2 elements

i.e.

DON'T:
CREATE TABLE [dbo].[Person] (
    ...
    [Gender]    VARCHAR(1)  NOT NULL,
    ...
)


DO:
CREATE TABLE [dbo].[Person] (
    ...
    [Gender]    CHAR(1)     NOT NULL,
    ...
)
There is a Code Analysis option in DataDude that checks for this (SR0009).

Comments

Popular Posts