Answers

Question and Answer:

  Home  MS SQL Server

⟩ What Are Character String Data Types in MS SQL Server?

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

 131 views

More Questions for you: