<legend id='XOUdx'><style id='XOUdx'><dir id='XOUdx'><q id='XOUdx'></q></dir></style></legend>

    1. <i id='XOUdx'><tr id='XOUdx'><dt id='XOUdx'><q id='XOUdx'><span id='XOUdx'><b id='XOUdx'><form id='XOUdx'><ins id='XOUdx'></ins><ul id='XOUdx'></ul><sub id='XOUdx'></sub></form><legend id='XOUdx'></legend><bdo id='XOUdx'><pre id='XOUdx'><center id='XOUdx'></center></pre></bdo></b><th id='XOUdx'></th></span></q></dt></tr></i><div id='XOUdx'><tfoot id='XOUdx'></tfoot><dl id='XOUdx'><fieldset id='XOUdx'></fieldset></dl></div>
      • <bdo id='XOUdx'></bdo><ul id='XOUdx'></ul>
    2. <tfoot id='XOUdx'></tfoot>

      <small id='XOUdx'></small><noframes id='XOUdx'>

      存储过程参数“NULL"或“= NULL"

      时间:2023-08-19

        <small id='9OJqC'></small><noframes id='9OJqC'>

        <i id='9OJqC'><tr id='9OJqC'><dt id='9OJqC'><q id='9OJqC'><span id='9OJqC'><b id='9OJqC'><form id='9OJqC'><ins id='9OJqC'></ins><ul id='9OJqC'></ul><sub id='9OJqC'></sub></form><legend id='9OJqC'></legend><bdo id='9OJqC'><pre id='9OJqC'><center id='9OJqC'></center></pre></bdo></b><th id='9OJqC'></th></span></q></dt></tr></i><div id='9OJqC'><tfoot id='9OJqC'></tfoot><dl id='9OJqC'><fieldset id='9OJqC'></fieldset></dl></div>
          <bdo id='9OJqC'></bdo><ul id='9OJqC'></ul>
          1. <legend id='9OJqC'><style id='9OJqC'><dir id='9OJqC'><q id='9OJqC'></q></dir></style></legend>

                <tbody id='9OJqC'></tbody>
            1. <tfoot id='9OJqC'></tfoot>

              • 本文介绍了存储过程参数“NULL"或“= NULL"的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

                问题描述

                有什么区别:

                CREATE PROCEDURE [dbo].[MyProcedure] 
                                @MyArgument INT NULL
                

                CREATE PROCEDURE [dbo].[MyProcedure] 
                                @MyArgument INT = NULL
                

                我使用了第一个,它在 SQL Server 2016 中运行良好.但 SQL Server 2012 不接受它.两者都适用于 SQL Server 2016,我现在使用第二个没有问题.但了解其中的差异会很有趣.

                I used the first one, and it worked fine in SQL Server 2016. But SQL Server 2012 did not accept it. Both works on SQL Server 2016, and I am using the second one now without problem. But it would be interesting to know the difference.

                谢谢!

                推荐答案

                他们不做同样的事情.第二个为调用者未指定的情况定义默认值.第一个没有.

                They don't do the same thing. The second one defines a default value for the case that the caller doesn't specify one. The first one doesn't.

                本机编译存储过程的 Transact-SQL 语法"grammar 允许将参数数据类型声明为允许 NULLNOT NULL.这是为 Hekaton(内存优化表)引入的.

                The "Transact-SQL Syntax for Natively Compiled Stored Procedures" grammar allows parameter datatypes to be declared as allowing NULL or NOT NULL. This was introduced for Hekaton (memory optimised tables).

                虽然在存储过程的 Transact-SQL 语法"中没有记录为支持语法,但它看起来允许 NULL 但在 NOT NULL 和抛出错误.

                Though it isn't documented as supported for the grammar in "Transact-SQL Syntax for Stored Procedures" it looks like it allows NULL but balks at NOT NULL and throws an error.

                参数 '@MyArgument' 已声明为 NOT NULL.非空参数只支持本地编译的模块,除了用于内联表值函数.

                The parameter '@MyArgument' has been declared as NOT NULL. NOT NULL parameters are only supported with natively compiled modules, except for inline table-valued functions.

                显式指定 NULL 没有任何价值 - 这是默认且唯一的选项.常规存储过程没有声明性语法来指示参数必须NOT NULL.

                There is no value in specifying NULL explicitly - this is the default and only option. There is no declarative syntax for regular stored procs to indicate that parameters must be NOT NULL.

                这篇关于存储过程参数“NULL"或“= NULL"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

                上一篇:在 MySQL 中创建一个带有可选参数的函数 下一篇:适用于基于 ARM 的 Debian 设备的 Oracle Instant Clien

                相关文章

                最新文章

                <legend id='WMkyi'><style id='WMkyi'><dir id='WMkyi'><q id='WMkyi'></q></dir></style></legend>
                <i id='WMkyi'><tr id='WMkyi'><dt id='WMkyi'><q id='WMkyi'><span id='WMkyi'><b id='WMkyi'><form id='WMkyi'><ins id='WMkyi'></ins><ul id='WMkyi'></ul><sub id='WMkyi'></sub></form><legend id='WMkyi'></legend><bdo id='WMkyi'><pre id='WMkyi'><center id='WMkyi'></center></pre></bdo></b><th id='WMkyi'></th></span></q></dt></tr></i><div id='WMkyi'><tfoot id='WMkyi'></tfoot><dl id='WMkyi'><fieldset id='WMkyi'></fieldset></dl></div>

                <small id='WMkyi'></small><noframes id='WMkyi'>

                  <bdo id='WMkyi'></bdo><ul id='WMkyi'></ul>

              • <tfoot id='WMkyi'></tfoot>