title: Stored procedure tutorial
body: <p>Excuse me if not very good english.</p>
  
  <p>I'm starting to learn sql language, and I have difficulty with one of the basics I guess.</p>
  
  <p>I'm creating a table in my visual studio sql project:</p>
  
  <pre><code>CREATE TABLE [dbo].[Table]
  (
  [Id] INT NOT NULL PRIMARY KEY, 
  [w] VARCHAR(50) NULL, 
  [p] VARCHAR(50) NULL, 
  [g] VARCHAR(50) NULL, 
  [m] VARCHAR(50) NULL
  )
  </code></pre>
  
  <p>I think I got it right, it should store 4 strings per entry.</p>
  
  <p>Now, the next part is I want to create a stored procedure like so</p>
  
  <pre><code>procedure(string, letter)
  </code></pre>
  
  <p>String is a value from m field in the table, letter is one of 3 letters (w,g,p) and I want it to find me the m entry in the table and display the value the w g or p field has.</p>
  
  <p>So if I have entry that has Abra in the m field, and cadabra in g field, and I write procedure(Abra, g) I want it to display me cadabra.</p>
  
  <p><strong>EDIT:</strong></p>
  
  <p>Will this work?</p>
  
  <pre><code>Create  PROCEDURE p(
  
   @n_m VARCHAR(50)
   @o_j CHAR
  
   )
   AS
   BEGIN
  
   SELECT w FROM Table WHERE m=@n_m AND @o_j='w'
  
   SELECT p FROM Table WHERE m=@n_m AND @o_j='p'
  
   SELECT g FROM Table WHERE m=@n_m AND @o_j='g'
   END
  </code></pre>