title: SQL Creating a procedure, but it doesn't see my tables
body: <p>I created a new database called <code>sample1</code>. In it I created 3 tables: &quot;address, contact and buyer&quot;</p>
  <pre><code>CREATE TABLE address
  (
      address_id int NOT NULL identity(1,1) primary key,
      street_name varchar(30)
  );
  
  CREATE TABLE contact
  (
      contact_id int NOT NULL identity(1,1) primary key,
      phone_num varchar(20) NOT NULL,
      address_id int NOT NULL foreign key REFERENCES address(address_id)
  );
  
  CREATE TABLE buyer
  (
      username char(20) NOT NULL primary key,
      name char(40) NOT NULL, 
      contact_id int NOT NULL foreign key REFERENCES contact(contact_id)
  );
  </code></pre>
  <p>The tables were created successfully, now I'm trying to create a stored procedure as follows:</p>
  <pre><code>create procedure csc
  (
      @username char(20),
      @address_id int,
      @contact_id int
  )
  as
  set nocount on;
  insert into [dbo].[buyer] values (@username);
  insert into [dbo].[address_id] values (@address_id);
  insert into [dbo].[contact_id] values (@contact_id);
  go
  </code></pre>
  <p>But I get the following errors:</p>
  <blockquote>
  <p>Msg 137, Level 15, State 2, Line 4<br />
  Must declare the scalar variable &quot;@username&quot;.</p>
  <p>Msg 137, Level 15, State 2, Line 10<br />
  Must declare the scalar variable &quot;@username&quot;.</p>
  <p>Msg 137, Level 15, State 2, Line 11<br />
  Must declare the scalar variable &quot;@address_id&quot;.</p>
  <p>Msg 137, Level 15, State 2, Line 12<br />
  Must declare the scalar variable &quot;@contact_id&quot;.</p>
  </blockquote>
  <p>My questions / errors:</p>
  <ol>
  <li><p>Are my tables logical? Should I be using buyer username as the PK for address / contact ID (my teacher suggested this, but I think it's bad practice)</p>
  </li>
  <li><p>When creating my procedure, I get red lines on [dbo].[buyer], [dbo].
  [address_id], [dbo].[contact_id], can I ignore these?</p>
  </li>
  <li><p>How in the world do I fix the errors?</p>
  </li>
  </ol>
  <p>Thanks in advance.</p>