Quantcast
Channel: SQL Server Expert – SQL Steve
Viewing all articles
Browse latest Browse all 9

Type Conversion Precedence

0
0

Here’s an interesting question:

What is the resulting data type of the following query?

SELECT’38’
UNION
SELECT 94

The answer is an “int”.  The reason for this is SQL Server’s precedence order.  It turns out that int has a higher precedence that varchar or nvarchar.  Since 94 is an int, they are both ints.

The complete list of data type precedences can be found here: http://msdn.microsoft.com/en-us/library/ms190309(v=SQL.105).aspx.

——————————–

SQL Server Expert, Steve Abraham, holds 8 Microsoft certifications and specializes in SQL Server and .Net Framework architecture, high availability, capacity planning, development, and performance tuning, and SQL Server Recovery.


Filed under: SQL Server, SQL Server 2005, SQL Server 2008, T-SQL Tagged: SQL Server, SQL Server 2005, SQL Server 2008, SQL Server Expert, SQL Server Recovery

Viewing all articles
Browse latest Browse all 9

Latest Images

Trending Articles





Latest Images