Transact-SQL DEFAULT关键字已弃用?为什么? [英] Transact-SQL DEFAULT keyword deprecated? Why?
问题描述
在MSDN文章中 SQL Server 2016中不推荐使用的数据库引擎功能关于不赞成使用 DEFAULT
关键字的声明(以及其他).
In MSDN article
Deprecated Database Engine Features in SQL Server 2016
there is a statement on deprecation of DEFAULT
keyword (among the others).
从表中引用:
类别: Transact-SQL
Category: Transact-SQL
不推荐使用的功能:使用DEFAULT关键字作为默认值.
Deprecated feature: Use of DEFAULT keyword as default value.
替换:请勿将单词DEFAULT用作默认值.
Replacement: Do not use the word DEFAULT as a default value.
功能名称: DEFAULT关键字作为默认值.
Feature name: DEFAULT keyword as a default value.
功能ID: 187.
此更改背后的逻辑是什么?我发现没错
What is the logic behind this change? I find nothing wrong with
CREATE FUNCTION dbo.GetFirstIdByCode(@Code nvarchar(20), @ExcludeThisId int)
在大多数情况下,在我不使用第二个参数的情况下,将其命名为
and in most cases, where I don't use 2nd parameter, call it like
IF dbo.GetFirstIdByCode(@Id, DEFAULT) = 0 --- etc...
当然,我可以在每次调用该函数时将 DEFAULT
替换为NULL.在我看来,这似乎只是进步.为什么要计划这个?
Of course, I can replace DEFAULT
with NULL at every call of the function. To me, this looks like anything but a progress. Why is this planned?
我应该如何调整我的编码风格以为此做准备?
How should I adjust my coding style preparing for this?
推荐答案
The wording was incorrect:Erland raised a connect item for this..please see this connect for more details..
从关联项目粘贴相关项目:
已弃用的功能是..
使用单词DEFAULT作为DEFAULT值.
using the word DEFAULT as the DEFAULT value.
示例:
CREATE TABLE T1
(Col1 int PRIMARY KEY,
Status varchar(10) DEFAULT 'DEFAULT' )
or
CREATE DEFAULT phonedflt AS 'DEFAULT'
这篇关于Transact-SQL DEFAULT关键字已弃用?为什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!