Simple way to programmatically get all stored procedures

后端 未结 12 2176
没有蜡笔的小新
没有蜡笔的小新 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:33

    You can use:

    DataTable  dtProcs = sqlConn.GetSchema("Procedures", new string[] { databaseName });
    DataTable  dtProcParams = sqlConn.GetSchema("ProcedureParameters", new string[] { databaseName });
    

    You can also get all sorts of other schema info like tables, indexes etc. if you need them.

    You can get info on GetSchema() here and info on the SQL Server Schema Collections here

    Edit: Sorry, this doesn't help with actually scripting the info, but I guess it's useful info to have.

提交回复
热议问题