Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there a way to turn off implicit type conversion in SQL Server?

Tags:

sql

sql-server

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'
like image 593
Yodiz Avatar asked Sep 30 '11 01:09

Yodiz


1 Answers

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.

like image 181
gbn Avatar answered Oct 04 '22 00:10

gbn