What is a SQL Server module?

前端 未结 4 1240
日久生厌
日久生厌 2021-01-19 01:54

I just came across the system view sys.sql_modules today. What is a module versus a DB object? The view returns, most prominently, a column containing the def

相关标签:
4条回答
  • 2021-01-19 02:39

    It's the blocks of T-SQL statements that make up a stored procedure, a stored function, a trigger or a view definition.

    From "Books Online" in the "CREATE PROCEDURE" section:

    Getting Information About Stored Procedures To display the definition of a Transact-SQL stored procedure, use the sys.sql_modules catalog view in the database in which the procedure exists.

    In sys.sql_modules, you'll find the actual T-SQL code.

    Marc

    0 讨论(0)
  • 2021-01-19 02:43

    A module, in SQL-Server-speak is a stand-alone object that contains sql batches, such as a view, table valued function, stored procedure, trigger or scalar function. A SQL object is a more all-encompassing term that includes some that contain SQL Expressions, such as check or default constraints. A module used to be referred to as a 'routine' before SQL Server 2005, but I think the two terms are used interchangeably.

    The table build script is not stored in SQL Server because of the ease with which components of a table can be altered separately. Therefore it is treated as an object but not a module.
    Typical objects that aren't also considered to be modules are system tables, default constraints, foreign key constraints, service queues, check constraints, user tables, primary key constraints, internal tables and unique constraints.

    Columns aren't considered to be objects. Neither are indexes.

    Yes, it is all more complex than one might first think.

    0 讨论(0)
  • 2021-01-19 02:48

    I came across to this question when I wanted to get detailed explanation of EXECUTE command. I wanted to have deep understanding how to read t-sql help of command and realized that I haven't known what module means.

    I just want to add these these to the list of sql modules:

    • system stored procedure,
    • user-defined stored procedure,
    • CLR stored procedure,
    • scalar-valued user-defined function,
    • or extended stored procedure.

    Executes a command string or character string within a Transact-SQL batch, or one of the following modules: system stored procedure, user-defined stored procedure, CLR stored procedure, scalar-valued user-defined function, or extended stored procedure. The EXECUTE statement can be used to send pass-through commands to linked servers. Additionally, the context in which a string or command is executed can be explicitly set. Metadata for the result set can be defined by using the WITH RESULT SETS options.

    https://docs.microsoft.com/en-us/sql/t-sql/language-elements/execute-transact-sql?view=sql-server-2017

    0 讨论(0)
  • 2021-01-19 02:53

    A modules are functions, procedures, queues, and triggers. These Modules call Objects. That's what I understood from this article which describes "EXECUTE AS":

    EXECUTE AS

    0 讨论(0)
提交回复
热议问题