SQL: CHAR vs VARCHAR

 SQL: CHAR vs VARCHAR


CHAR: 
SQL char stores fixed string length.  This means SQL Server char holds the maximum column space regardless of the string it holds.

VARCHAR:
SQL varchar stores variable string length. This means SQL Server varchar holds only the characters we assign to it.

CHAR is better than VARCHAR performance-wise, however, it takes up unnecessary memory space when the data does not have a fixed length. 
So in cases where disk size is not an issue, it is recommended to use CHAR.

No comments:

Post a Comment