Follow our table rules: columns and datatypes
You SHOULD:-
-
Specify the nullability on columns.
-
Define column data types (such as
VARCHARandCHAR) appropriately. -
Specify the length of a character column, even if you want it to be one. This rule applies when also declaring or casting variable datatypes.
-
Use fixed-length datatypes rather than declaring variables as variable length of length 1 or 2.
-
Include the precision and scale (when supported) when specifying numeric types. This prevents you being bound to the default values.
-
Follow good database design practices. And if you consider yourself an 'Accidental DBA' be sure to read the 'Accidental DBA guide'!
You SHOULD NOT:-
-
Use the
CHARorNCHARdata type for columns that permitNULLvalues. -
Use
VARCHAR(MAX)when unnecessary. -
Use the
TEXTorNTEXTdatatypes. -
Declare variables without a datatype length. For example,
DECLARE@MyVar VARCHAR;is to be avoided. -
Use inappropriate datatypes. For example, storing numbers or dates as
VARCHAR.