Use the SQL Server VARCHAR data type to define columns, variables, and parameters variable length characters. VARCHAR types are variable in length. They do not take up more memory than the characters stored. This differs from the CHAR type, which always occupies the full amount defined.
The VARCHAR type stores up to 8000 characters with each character taking one byte. VARCHAR is well suited for storing ASCII data. If you need to store characters from Asian languages, such as Kanji, or other UNICODE character sets, then use NVARCHAR.
Here, we use VARCHAR to define a Person table with FirstName as 20 in length, and LastName 40 in length:
CREATE TABLE Person ( PersonID INT NOT NULL, FirstName VARCHAR(20), LastName VARCHAR(40) )
Here we declare a variable:
DECLARE @firstName VARCHAR(20);
Additional VARCHAR Resources
To learn more about SQL Server data types, check out these useful resources: