Data types and Precedence of convert types
SQL Server associates columns, expressions, variables, and parameters with data types. Data types determine what kind of data can be stored in the field: Integers, characters, dates, money, binary strings, etc.
SQL Server supplies several built-in data types but you can also define custom types
Built-in data types are categorized as shown in the table below, also you can see the precedence of convert to other data type. I mean when an operator combines two expressions of different data types, the rules for data type precedence specify that the data type with the lower precedence is converted to the data type with the higher precedence.
SQL Server uses the following precedence order for data types:
- user-defined data types (highest)
- sql_varian t
- nvarchar (including nvarchar(max) )
- varchar (including varchar(max) )
- varbinary (including varbinary(max) )
- binary (lowest)