Zahid Zahid - 2 months ago 5x
SQL Question

Output of SQL query

I have a problem where I was asked what will return by the simple query.

The query is

Select 5 + '4'

As, 4 is string type, I expect the query will throw an error. Later, I found I was wrong, and tested it gave 9 as result. How does it return the sum?


If you mix data types such as INT and VARCHAR, SQL Server will always attempt to convert everything to the one that has the highest precedence.