There is one topic in query and equation writing that is constantly a minor issue for SQL programmers: implicit data type conversions. Whenever you don’t specifically state the datatype of an expression, like when you write
SELECT 1;, it can feel a bit of a mystery what the datatypes of your literal values are. Like in this case, what is 1 ? You probably know from experience that this is an integer, but then what happens when you compareCAST(1 as bit)to the literal 1. Is that literal 1 now a bit? Or is it still an integer?Perhaps even more importantly, why does this query succeed?
Click through to learn more.
Leave a Comment