What Are the Differences between CHAR and VARCHAR in MS SQL Server?
Submitted by: AdministratorCHAR and VARCHAR are both used to store code page based character strings. But they have the following main differences:
* CHAR(n) stores character strings with a fixed length, n bytes, storage format.
* VARCHAR(n) stores character strings with a variable length, less than n bytes, storage format.
* If the input string of CHAR(n) has less than n bytes, it will be padded with space characters to become n bytes.
* If the input string of VARCHAR(n) has less than n bytes, it will not be padded with any characters.
* If the input string of CHAR(n) has more than n bytes, it will be truncated to n bytes.
* If the input string of VARCHAR(n) has more than n bytes, it will also be truncated to n bytes.
Submitted by: Administrator
* CHAR(n) stores character strings with a fixed length, n bytes, storage format.
* VARCHAR(n) stores character strings with a variable length, less than n bytes, storage format.
* If the input string of CHAR(n) has less than n bytes, it will be padded with space characters to become n bytes.
* If the input string of VARCHAR(n) has less than n bytes, it will not be padded with any characters.
* If the input string of CHAR(n) has more than n bytes, it will be truncated to n bytes.
* If the input string of VARCHAR(n) has more than n bytes, it will also be truncated to n bytes.
Submitted by: Administrator
Read Online MS SQL Server Job Interview Questions And Answers
Top MS SQL Server Questions
☺ | How To Start SQL Server Browser Service? |
☺ | How To Execute the Cursor Queries with "OPEN" Statements? |
☺ | How To Test ODBC DSN Connection Settings? |
☺ | PHP MSSQL - How To Display a Past Time in Days, Hours and Minutes? |
☺ | How To Create a Testing Table with Test Data in MS SQL Server? |
Top Databases Programming Categories
☺ | RDBMS Interview Questions. |
☺ | SQL Interview Questions. |
☺ | SSRS Interview Questions. |
☺ | Database Administrator (DBA) Interview Questions. |
☺ | Sybase Interview Questions. |