title: SQL Server 2008R2 - INSERT from Multiple Tables
body: <p>I am having an issue (well two issues actually) with my stored procedure, and I could be making a rookie error here but I've attempted to fix it and failed miserably. Enter the gurus of stack overflow to save me :D</p>
  
  <p>I want to be able to insert a new appointment into my appointment table using a stored procedure (the workings of it below). The problem is that I am trying to get the Stylist and Client ID's by the input of their names (obviously these are in separate tables and you can see where I've tried to get a hold of the ID's in the code snippet...) Anyway, I haven't got any errors as such, but it doesn't actually DO anything, as in nothing gets inserted into the appointments table when the stored procedure is tested (it executes fine). I am not sure why this is and I have no idea where to start looking.</p>
  
  <p>There is one other issue which may be related, and that's the c.fullName and s.fullName are constantly underlined with a red line and it says they could not be found. BOTH of these columns exist in the client and stylist tables; they are both computed columns (firstname + lastname) and work in other queries just fine, so I don't understand why they don't work here.</p>
  
  <pre><code>@AppDate date = null,
  @AppTime time(5) = null,
  @Details varchar(255) = null,
  @ClientName varchar(50) = null,
  @StylistName varchar(50) = null,
  @ClientID int = null,
  @StylistID int = null
  
  INSERT into appointment(appDate, appTime, details, clientID, stylistID)
  SELECT
      @AppDate AS appDate, 
      @AppTime AS appTime, 
      @Details AS details,
      @ClientID, 
      @StylistID
  FROM appointment a
  JOIN client c 
  ON c.clientID = a.clientID
  JOIN stylist s
  ON s.stylistID = a.stylistID
  WHERE c.fullName = @ClientName
  AND s.fullName = @StylistName
  </code></pre>
  
  <p>Any ideas or tips would be very much appreciated :)</p>
  
  <p>EDIT:
  I just noticed that when I logged out and back in again it removed the issues with the fullName columns - I did try this before but it didn't work, but obviously now it doesn't seem to be an issue... the stored procedure still doesn't insert anything though :(</p>