如何修改 Master dbo 中的 SQL Server 存储过程?

问题描述 投票:0回答:1

我运行查询来查找 SQL Server SSMS(版本 18.12.1)中的所有存储过程。它从 Master 数据库(由 db_name 定义)返回一个存储过程。我知道如何通过查看可编程性/存储采购来找到典型数据库中的那些内容,但不知道如何在主数据库中找到它。有什么想法吗?

我尝试查看 SQL Server 对象资源管理器,但找不到它。

这是我用来返回具有给定搜索模式的对象列表的过程:

DECLARE @SearchString varchar(120) = 'xxxx'


DECLARE @strSQL varchar(MAX) = '
USE [?];

BEGIN
DECLARE 
    @SearchStr varchar(200) 
    SET @SearchStr = ''%' + @SearchString + '%''; 
SELECT DISTINCT
    ''?'' as db_name, o.name
    , ( CASE upper(o.xtype) 
            WHEN ''C'' THEN ''CHECK constraint''        
            WHEN ''D'' THEN ''Default or DEFAULT constraint''                       
            WHEN ''F'' THEN ''FOREIGN KEY constraint''  
            WHEN ''L'' THEN ''Log''                                                                 
            WHEN ''FN'' THEN ''Scalar function''        
            WHEN ''IF'' THEN ''Inline table-function''
            WHEN ''PK'' THEN ''PRIMARY KEY or UNIQUE constraint''
            WHEN ''P'' THEN ''Stored procedure''                                            
            WHEN ''R'' THEN ''Rule''                    
            WHEN ''RF'' THEN ''Replication filter stored procedure''            
            WHEN ''S'' THEN ''System table''            
            WHEN ''TF'' THEN ''Table function''
            WHEN ''TR'' THEN ''Trigger''                
            WHEN ''U'' THEN ''User table''      
            WHEN ''V'' THEN ''View''                    
            WHEN ''UQ'' THEN ''UNIQUE constraint (type is K)''                  
            WHEN ''X'' THEN ''Extended stored procedure''                           
        ELSE upper(o.xtype) END ) Type
    , ( CASE upper(o.xtype)
            WHEN ''PK'' THEN ( select object_name(parent_object_id) FROM sys.key_constraints (nolock) WHERE o.name=name )
            WHEN ''F'' THEN ( select object_name(parent_object_id) FROM sys.foreign_keys (nolock) WHERE o.name=name )
            WHEN ''TR'' THEN ( select object_name(parent_id) FROM sys.triggers (nolock) WHERE o.name=name )     
        ELSE '''' END ) as Parent_Object
FROM sysobjects o (nolock) 
INNER JOIN syscomments sc (nolock) ON o.id = sc.id
WHERE UPPER( text ) LIKE UPPER( @SearchStr ) AND substring(o.name,1,3)<> ''dt_'' 
GROUP BY o.name, o.xtype
END'


exec sp_msforeachdb @strSQL
GO
sql-server stored-procedures ssms
1个回答
0
投票

如果您使用的是 SSMS(SQL Server Management Studio),则必须单击“系统数据库”才能找到主数据库。如果没有,那么我不知道为什么你找不到大师,它应该总是可以访问的。

看起来像

© www.soinside.com 2019 - 2024. All rights reserved.