title: Executing a system stored procedure (sys.sp_helptext) from a client app without a user wrapper proc
body: <p>I would like to create a C# method that accepts one parameter, the name of a stored procedure. The method will then execute the following system stored procedure directly without using a user-defined sub routine to wrap this call.</p>
  
  <pre><code>sys.sp_helptext 'proc name'
  </code></pre>
  
  <p>I get the error:</p>
  
  <blockquote>
    <p>Could not find stored procedure 'sys.sp_help_text</p>
  </blockquote>
  
  <p>Is this a permissions issue (I am Admin of my test db) or qualification issue? </p>
  
  <pre><code>public static string GetStoredProcedure(string objectName, string connectionString)
  {
  
      using (SqlConnection sqlConnection = new SqlConnection())
      {
          sqlConnection.ConnectionString = connectionString;
          sqlConnection.Open();
          SqlCommand sqlCommand = new SqlCommand("sys.sp_help_text", sqlConnection);
          sqlCommand.CommandType = CommandType.StoredProcedure;
          sqlCommand.Parameters.AddWithValue("@objname", objectName);
          DataSet ds = new DataSet();
          SqlDataAdapter sqlDataAdapter = new SqlDataAdapter();
          sqlDataAdapter.SelectCommand = sqlCommand;
          sqlDataAdapter.Fill(ds);
          return DataTableToString(ds.Tables[0]);;   
      }
  }     
  </code></pre>