Académique Documents
Professionnel Documents
Culture Documents
4/3/2012
Jagdish Devaku
Data types are classified into the following categories: 1. 2. 3. 4. 5. 6. 7. Exact numeric's Unicode character strings Approximate numeric's Binary strings Date and time Other data types Character strings
In SQL Server, based on their storage characteristics, some data types are designated as belonging to the following groups: Large value data types: varchar(max), nvarchar(max), and varbinary(max) Large object data types: text, ntext, image, varchar(max), nvarchar(max), varbinary(max), and xml
Jagdish Devaku 2
4/3/2012
Exact Numeric's:
1. bigint -> -2^63 (-9,223,372,036,854,775,808) to 2^63-1 (9,223,372,036,854,775,807) -> 8 Bytes 2. numeric -> - 10^38 +1 through 10^38 1 (1 to 38 P) 3. bit -> 1, 0, or NULL (1 to 8 cols in a table 1 byte & 9 to 16 cols 2bytes) 4. smallint -> -2^15 (-32,768) to 2^15-1 (32,767) -> 2 Bytes
Approximate Numeric's: 1. Float -> - 1.79E+308 to -2.23E-308, 0 and 2.23E-308 to 1.79E+308 (depends on the value of n)
float [ (n) ] : Where n is the number of bits that are used to store the mantissa of the float number in scientific notation and, therefore, dictates the precision and storage size. If n is specified, it must be a value between 1 and 53. The default value of n is 53. nvalue 1-24 25-53 Precision 7 digits 15 digits Storage size 4 bytes 8 bytes
4/3/2012
Jagdish Devaku
4/3/2012
Jagdish Devaku
Character Strings:
1. Char (Character) -> char [ ( n ) ]: Fixed-length, non-Unicode character data with a length of n bytes. n must be a value from 1 through 8,000. The storage size is n bytes. 2. Varchar (Char Varying Or Character Varying) -> Variable-length, non-Unicode character data. varchar [(n)]: n can be a value from 1 through 8,000.
varchar [(max)]: max indicates that the maximum storage size is 2^31-1 bytes.
The storage size is the actual length of data entered + 2 bytes.
3. Ntext (National Text) -> Variable-length Unicode data with a maximum length of 2^30 - 1 (1,073,741,823) characters. Storage size, in bytes, is two times the number of characters entered.
4/3/2012 Jagdish Devaku 7
Binary Strings:
1. Binary -> Binary [ ( n ) ]: Fixed-length binary data with a length of n bytes, where n is a value from 1 through 8,000. The storage size is n bytes. 2. Varbinary (Binary Varying) -> Variable-length binary data. varbinary [(n)]: ncan be a value from 1 through 8,000. varbinary [(max)]: max indicates that the maximum storage size is 2^31-1 bytes. The storage size is the actual length of the data entered + 2 bytes. Default n value is 1 and 30 when used in CAST OR CONVERT. 3. Image -> Variable-length binary data from 0 through 2^31-1 (2,147,483,647) bytes.
4/3/2012
Jagdish Devaku
2. Timestamp -> This will be removed in future versions of SQL Server. Avoid using this feature. This is used in the versioning mechanism.
3. Hierarchyid -> The hierarchyid data type is a variable length, system data type. Use hierarchyid to represent position in a hierarchy.
4. Uniqueidentifier -> Is a 16-byte GUID. A column or local variable of uniqueidentifier data type can be initialized to a value by using the NEWID function.
4/3/2012
Jagdish Devaku
4/3/2012
Jagdish Devaku
10
Thank You
4/3/2012
Jagdish Devaku
11