title: How to create a stored procedure for select/update/delete statements
body: <p>I have this sql statement that I want to convert to store procedure. How can I do that? </p>
  
  <pre><code>select a.name, a.lastname, from myTable where b.name= a.lastname
  </code></pre>
  
  <p>Thanks</p>
  
  <p>UPDATE
  Would this be right guys</p>
  
  <pre><code>CREATE PROCEDURE myProcedure
  AS
  BEGIN
  SELECT [a.name],
         [a.lastname]
  FROM [myTable]
  WHERE [b.name] = a.lastname
  END
  </code></pre>
  
  <p>This is one of the code that I am really working on</p>
  
  <p>sql statement</p>
  
  <pre><code>SELECT RTRIM(l.Lab1) + '/' + RTRIM(l.LabR) AS Lab, meta.Title,ls.[ID],ls.[surveyID], ls.[specialistID],ls.[isCompleted] FROM [MyDIM].[dbo].[lsLabSurvey] ls JOIN [MYDIM].[dbo].[dimDocMetaInfo] meta ON meta.id = ls.[surveyID] and specialistID = @PID and isCompleted=1 JOIN MyDatabase.DBO.PID_Table l ON ls.ID = l.ID
  </code></pre>
  
  <p>And My Attempted Stored Procedure</p>
  
  <pre><code>CREATE PROCEDURE PROCD1
  AS
  BEGIN
  SELECT RTRIM(l.Lab1) + '/' + RTRIM(l.LabR) 
  AS Lab, 
     meta.Title,
     la.[ID],
     ls.[surveyID],
     ls.[specialistID],
     ls.[isCompleted]
  FROM [MyDIM].[dbo].[lsLabSurvey] ls 
  JOIN [MyDIM].[dbo].[dimDocMetaInfo] meta 
  ON meta.id = ls.[surveyID] 
  and specialistID = @PID 
  and isCompleted=1 
  JOIN MyDatabase.DBO.PID_Table l 
  ON ls.ID = l.ID 
  </code></pre>
  
  <p>END</p>