使用Smo管理对象,可以很方便的列举指定数据库中的所有存储过程和其参数

using System;
using System.Collections.Generic;
using System.Text;
using System.Net;
using System.IO;
using Microsoft.SqlServer.Management.Smo;

namespace ConsoleApplication7
{
    
class Program
    {
        
static void Main(string[] args)
        {
            Server server 
= new Server(".");
            Database db 
= server.Databases["YouDBName"];
            
            
foreach (StoredProcedure sp in db.StoredProcedures)
            {
                
if (sp.IsSystemObject)
                {
                    
continue;
                }
                Console.WriteLine(sp.Name);
                
foreach (Parameter parm in sp.Parameters)
                {
                    Console.WriteLine(
"\t" + parm.Name + "\t\t" + parm.DataType.SqlDataType.ToString());
                }
            }
         
            Console.Read();
        }
    }
}

 

需要引用Microsoft.SqlServer.ConnectionInfo和Microsoft.SqlServer.Smo两个组件。

相关文章:

  • 2021-06-13
  • 2022-12-23
  • 2022-12-23
  • 2021-08-18
  • 2022-01-21
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-01-02
  • 2022-12-23
  • 2021-12-19
  • 2021-07-09
相关资源
相似解决方案