Following up to my last post on understanding numeric data types in SQL Server, in this post I would like to touch on the issue of string data types. One perhaps may want to call them non-numeric data types, however I would not be quick to say so as there is an in-between group of data types that has roots in both numeric data types and string data types.
Lets start off my defining what a “string” is. In computer programming terms, a string is a sequence or characters, be it alphabetical characters or alpha numeric characters. Hence as such, “string” data types are well suited to store normal text values formed by everyday words or phrases. So what string data types does SQL Server provide us?
|char||Character data with fixed length|
|varchar||Character data with variable length|
|text||Deprecated. Variable-length non-Unicode data with a maximum length of 2,147,483,647 characters. Use varchar(max) instead|
|Unicode Character Strings|
|nchar||Character data with fixed length|
|nvarchar||Character data with variable length|
|ntext||Deprecated. Variable-length non-Unicode data with a maximum length of 2,147,483,647 characters. Use varchar(max) instead|
|Binary Character Strings|
|binary||Binary data with fixed length|
|varbinary||Binary data with variable length|
|image||Deprecated. Use varbinary(max) instead|
From the table above you will see that there are 3 sets of string data types, the first is the standard string data types (char, varchar and text). The text data type will however be not available in future releases of SQL Server. These data types can accomodation English and some European languages. To accommodate other languages like Chinese, Japanese, Arabic and so on, you would need to use the Unicode string data types which include nchar, nvarchar and ntext. SQL Server, also allows of data storage in binary format.
So in conclusion, coupling the blog post “Understanding SQL Server Numeric Data Type” and this one, we see that SQL Server allows you to pretty much store any type of data in your database and most importantly in the language of your choice!