August 2012
Intermediate to advanced
1416 pages
33h 39m
English
Now you may be wondering, data types, isn't this section all about expressions and functions? You are correct. However, before discussing those important aspects of T-SQL, here's a quick overview of the various data types available in SQL Server. Understanding these different types are pivotal when it comes to building expressions and using the scalar functions in an effective and efficient manner.
SQL Server supports several character data types, as listed in Table 8.1.
Table 8.1 Character Data Types
| Data Type | Description | Size in Bytes |
| Char(n) | Fixed-length character data up to 8,000 characters long using collation character set | Defined length * 1 byte |
| Nchar(n) | Unicode fixed-length character data | Defined length * 2 bytes |
| VarChar(n) | Variable-length character data up to 8,000 characters long using collation character set | 1 byte per character |
| VarChar(max) | Variable-length character data up to 2GB in length using collation character set | 1 byte per character |
| nVarChar(n) | Unicode variable-length character data up to 8,000 characters long using collation character set | 2 bytes per character |
| nVarChar(max) | Unicode variable-length character data up to 2GB in length using collation character set | 2 bytes per character |
| Text | Variable-length character data up to 2,147,483,647 characters in length Warning: Deprecated | 1 byte per character |
| nText | Unicode variable-length character data up to 1,073,741,823 characters in length Warning: Deprecated | 2 bytes per ... |
Read now
Unlock full access