如何在 SQL 服务器中检索系统对象代码或定义?

How to retrieve system object code or definition in SQL Server?

您好,我正在使用 SQL Server 2012。我想查看系统对象 code/definition。我们可以在 SQL 服务器任何版本中查看系统对象 definition/code 吗? 想知道我何时执行此查询 SELECT MONTH(18/200), MONTH(200/18) 我得到输出 1 只是想知道内部代码发生了什么以及它如何给出输出 1一个月(200/18)?要了解这一点,请查找 MONTH() 函数代码。

使用INFORMATION_SCHEMA

An information schema view is one of several methods SQL Server provides for obtaining metadata.

Information schema views provide an internal, system table-independent view of the SQL Server metadata.

Information schema views enable applications to work correctly although significant changes have been made to the underlying system tables.

The information schema views included in SQL Server comply with the ISO standard definition for the INFORMATION_SCHEMA.

回答 SELECT MONTH(18/200),MONTH(200/18) 是 MONTH() 的任何整数,将 0 解释为 1900 年 1 月 1 日。这就是它返回 1 1 作为输出的原因.