title: How to convert Inline SQL to a stored procedure in SQL Server
body: <p>My code shown below is create as an inline SQL statement. How can this code be written as a stored procedure??</p>
  
  <p>The code is:</p>
  
  <pre><code>public Stream SelectEmployeeImageByID(int theID)
  {
          SqlConnection connection = new SqlConnection(ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString.ToString());
          string sql = "SELECT Image FROM Employees WHERE EmployeeId = @EmployeeId";
          SqlCommand cmd = new SqlCommand(sql, connection);
          cmd.CommandType = CommandType.Text;
          cmd.Parameters.AddWithValue("@EmployeeId", theID);
  
          connection.Open();
          object theImg = cmd.ExecuteScalar();
  
          try
          {
              return new MemoryStream((byte[])theImg);
          }
          catch
          {
              return null;
          }
          finally
          {
              connection.Close();
          }
      }
  </code></pre>