Yodiz
Yodiz

Reputation: 258

Is there a way to turn off implicit type conversion in 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'

Upvotes: 13

Views: 6298

Answers (2)

gbn
gbn

Reputation: 432662

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.

Upvotes: 10

Joe
Joe

Reputation: 42666

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.

Upvotes: 0

Related Questions