As the title indicates: Is there a way to turn off implicit type conversion in SQL Server?
I want the following simple SQL to generate an error
SELECT 'a' WHERE 1='1'
As the title indicates: Is there a way to turn off implicit type conversion in SQL Server?
I want the following simple SQL to generate an error
SELECT 'a' WHERE 1='1'
There is no way to disable it.
It has been requested though: see the proposed SET OPTION STRICT ON
MS Connect request which comes from Erland Sommarskog
However, it is utterly predictable according to datatype precedence rules
Your example of a foreign key is interesting because an actual FOREIGN KEY constraint requires the same datatype, length and collation.
There is no way to disable the implicit conversions in SQL server, though some searching will show that it is something a number of people have asked for.
© 2022 - 2024 — McMap. All rights reserved.
select * from foo where c = 123
will cause the strange errorConversion failed when converting the varchar value 'ABC' to data type int.
Nowhere in my query did I ask to convert 'ABC' to anything; instead, this value is in column c somewhere. Much more helpful if MSSQL would warn me that I have specified an int when the column type is char. – Danielledaniels