【问题标题】:How to see content/description of a function in SQL Server [duplicate]如何在 SQL Server 中查看函数的内容/描述 [重复]
【发布时间】:2018-08-09 13:23:32
【问题描述】:

如何在 SQL Server 中查看函数的内容/描述

【问题讨论】:

标签: sql sql-server


【解决方案1】:

以下是您可以遵循的示例

USE AdventureWorks2012;  
    GO  
    -- Get the function name, definition, and relevant properties  
    SELECT sm.object_id,   
       OBJECT_NAME(sm.object_id) AS object_name,   
       o.type,   
       o.type_desc,   
       sm.definition,  
       sm.uses_ansi_nulls,  
       sm.uses_quoted_identifier,  
       sm.is_schema_bound,  
       sm.execute_as_principal_id  
    -- using the two system tables sys.sql_modules and sys.objects  
    FROM sys.sql_modules AS sm  
    JOIN sys.objects AS o ON sm.object_id = o.object_id  
    -- from the function 'dbo.ufnGetProductDealerPrice'  
    WHERE sm.object_id = OBJECT_ID('dbo.ufnGetProductDealerPrice')  
    ORDER BY o.type;  
    GO  

https://docs.microsoft.com/en-us/sql/relational-databases/user-defined-functions/view-user-defined-functions?view=sql-server-2017

【讨论】:

    【解决方案2】:
    sp_helptext N'objectName'
    

    objectName 可以是存储过程或函数名

    【讨论】:

      【解决方案3】:

      你可以像sp_helptext一样使用

      sp_helptext procedure_name
      

      【讨论】:

        猜你喜欢
        • 2022-01-14
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2014-06-30
        • 1970-01-01
        • 2013-03-09
        • 1970-01-01
        相关资源
        最近更新 更多