Posts

Showing posts with the label data type

70-461 Training Kit Chapter 2, Lesson 2: Data Type

Data Type: Is a constraint Encapsulates behavior Relational Model's Physical Data Independence Let the storage engine take care of the internal storage format Exact Numeric: TINYINT (1 byte) SMALLINT (2 bytes) INT (4 bytes) BIGINT (8 bytes) NUMBERIC (size varies depend on precision) DECIMAL (size varies depend on precision) SMALLMONEY(4 bytes) MONEY(8 bytes) Approximate Numeric REAL (4 bytes) FLOAT Character non-Unicode (CHAR, VARCHAR) support only one language based on collation properties 1 byte/character Use single quotation marks, 'xyz', to indicate regular character strings (non-Unicode) Character Unicode (NCHAR, NVARCHAR) Unicode, support multiple language 2 bytes/character Use N'xyz', to indicate Unicode character string. Binary Strings: BINARY VARBINARY Image Date and Time: DATE (3 bytes) TIME (3 to 5 bytes) DATETIME2 (6 to 8 bytes) SMALLDATETIME (4 bytes) DATETIME (8 bytes) ...

70-461 Training Kit Chapter 2, Lesson 2: Data Type Precedence & Data Conversion

Here's the note for data conversion and data type precedence in SQL Server, part of 70-461 exam training kit, chapter 2. Data Conversion SQL Server often cast data type with lower precedence to a data type with higher precedence. Example:  2 + '2' = 4 because '2' is converted to an integer. Since an INT data type has higher precedence than a CHAR. Data Type Precedence of some data type User-defined (highest) Xml Datetime2 Datetime Smalldatetime Date Time Float Real Decimal Money Smallmoney Bigint Int Smallint Tinyint Bit Timestamp Uniqueidentifier Nvarchar Nchar Varchar Char Varbinary Binary (lowest) BOL Data type Precedence: http://msdn.microsoft.com/en-us/library/ms190309.aspx Microsoft 70-461 Training Kit