Simple way to programmatically get all stored procedures

后端 未结 12 2094
没有蜡笔的小新
没有蜡笔的小新 2020-12-24 09:22

Is there a way to get stored procedures from a SQL Server 2005 Express database using C#? I would like to export all of this data in the same manner that you can script it o

12条回答
  •  生来不讨喜
    2020-12-24 09:47

    This is a SQL that I have just tested and used in MSSQL

    SELECT NAME from SYS.PROCEDURES 
    order by name
    

    In case that you need to look for a specific name or substring/text

    SELECT NAME from SYS.PROCEDURES 
    where name like '%%'
    order by name
    

    Replace with exactly that for example:

    SELECT NAME from SYS.PROCEDURES 
    where name like '%CUSTOMER%'
    order by name
    

    And calling

    EXEC sp_HelpText SPNAME 
    

    for each stored procedure, you'll get a record set with one line of text per row

提交回复
热议问题