如何在SQL Server中查看功能的内容/说明

时间:2018-08-09 13:23:33

标签: sql sql-server

如何在SQL Server中查看功能的内容/说明

3 个答案:

答案 0 :(得分:0)

sp_helptext N'objectName'

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

答案 1 :(得分:0)

您可以像

一样使用sp_helptext
sp_helptext procedure_name

答案 2 :(得分:0)

下面是一个示例,您可以按照此操作

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