有没有办法在 SQL Server 中关闭隐式类型转换? [英] Is there a way to turn off implicit type conversion in SQL Server?

查看:30
本文介绍了有没有办法在 SQL Server 中关闭隐式类型转换?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

正如标题所示:有没有办法关闭 SQL Server 中的隐式类型转换?

As the title indicates: Is there a way to turn off implicit type conversion in SQL Server?

我希望以下简单的 SQL 生成错误

I want the following simple SQL to generate an error

SELECT 'a' WHERE 1='1'

推荐答案

没有办法禁用它.

虽然已请求:请参阅建议的 SET OPTIONSTRICT ON 来自 Erland Sommarskog

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

您的外键示例很有趣,因为实际的 FOREIGN KEY 约束需要相同的数据类型、长度和排序规则.

Your example of a foreign key is interesting because an actual FOREIGN KEY constraint requires the same datatype, length and collation.

这篇关于有没有办法在 SQL Server 中关闭隐式类型转换?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆