MS SQL Server Concepts and Programming Question:
Download Questions PDF

What Are Character String Data Types in MS SQL Server?

Answer:

Character string data types are used to store code page based character strings. SQL Server 2005 supports the following character string data types:

* CHAR - Code page based character strings with a fixed length of n bytes defined as CHAR(n). The maximum length is 8,000 bytes. CHAR has a synonym of CHARACTER.
* VARCHAR - Code page based character strings with a variable length of n bytes defined as VARCHAR(n). The maximum length is 8,000 bytes. VARCHAR has two synonyms of CHAR VARYING and CHARACTER VARYING. VARCHAR also has special form as VARCHAR(MAX), which can store up to 2^31-1 bytes.
* TEXT - Code page based character strings with a variable length up to 2^31-1 (2,147,483,647) bytes. TEXT is equivalent to VARCHAR(MAX).

Here are some good examples of character string values:

PRINT 'Hello! '; -- CHAR(10)
PRINT 'Hello!'; -- VARCHAR(10)
GO


Download MS SQL Server Interview Questions And Answers PDF

Previous QuestionNext Question
What Are Date and Time Data Types in MS SQL Server?What Are Unicode Character String Data Types in MS SQL Server?