Schema from stored procedure

前端 未结 5 1497
迷失自我
迷失自我 2020-12-21 10:30

I have a procedure, I want to read schema of the procedure. To retrieve view schema I use the query shown here. Same way I want to get schema of stored procedure. How to get

5条回答
  •  抹茶落季
    2020-12-21 11:05

    you could do

    public static DataTable SchemaReader(string tableName) 
    {      
      string sql = "MySP";//replace this with your store procedure name      
      conn.Open();      
      SqlCommand cmd = new SqlCommand(sql, conn);
      cmd.CommandType = CommandType.StoredProcedure;      
      SqlDataReader reader = cmd.ExecuteReader();       
      DataTable schema = reader.GetSchemaTable();       
      reader.Close();      
      conn.Close();      
      return schema; 
    }
    

    Hope this help

提交回复
热议问题