I have a web developer who sent me a query he couldn't figure out. Select Name from dbo.Employee where EmployeeID = ''. EmployeeID is an integer. First, I told him he shouldn't use '' as an integer. But, I could not explain why SQL Server converted '' to a zero. Can anyone answer that for me?
My assumption is that the engine sees a blank value as a zero because the column being compared to is an integer type. Since the value is nothing (not a null), the engine converts it to a zero because mathmatically zero added to anything doesn't change the value.