title: Create and execute stored procedure with parameter in SQL Server
body: <p>I have four tables:</p>
  
  <ul>
  <li>dbo.Projects (id, ProjectName, Areas, PaymentSystem, Districts.id, purpose.id, types.id, etc)</li>
  <li>dbo.Districts(id, DistrictsName)</li>
  <li>dbo.Purpose (id, PurposeName) - has residential &amp; commercial </li>
  <li>dbo.Types (id, typName)</li>
  </ul>
  
  <p>I want to select <code>DistrictsName</code> where <code>PurposeName = 'residential'</code></p>
  
  <p>This is my code I tried but it does not work ,not sure if it true or false,
  this is the result from execute this procedure: </p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-html lang-html prettyprint-override"><code>ID DistrictsName PurposeName 
   1   District1    residential
   2   District1    residential
   3   District2    residential
   4   District2    residential
  
  i want it to be like this :
  ID DistrictsName PurposeName 
   1   District1    residential
   2   District2    residential</code></pre>
  </div>
  </div>
  </p>
  
  <pre><code>CREATE PROCEDURE [dbo].[SearchResidentialProjects]   
  AS
      SELECT 
          dbo.Projects.ID,
          dbo.Districts.DistrictName,
          dbo.Purpose.PurposeName
      FROM 
          dbo.Projects 
      INNER JOIN 
          dbo.Purpose ON dbo.Projects.PurposeID = dbo.Purpose.ID 
      INNER JOIN  
          dbo.Districts ON dbo.Projects.DistrictID = dbo.Districts.ID
      WHERE 
          dbo.Purpose.PurposeName = N'Residential'
  </code></pre>
  
  <p>I'm new to SQL Server so any help is appreciated.</p>