title: Insert Procedure check if foreign key exists in another table
body: <p>I am running into an issue where I am supposed to create a stored procedure. However my stored procedure needs to check if columns exists in a different table, this is my code at the moment:</p>
  
  <pre><code> CREATE PROCEDURE InsertTrail ( 
   @Mount             int,
   @Skill             varchar(20),
   @Snow              int,
   @Lift              int, 
   @Open              char(3),
   @AmountReal        int,
   @AmountFake        int,
   @Name              varchar(50)
    )
  AS 
  BEGIN 
  If not exists (select mountainid from MOUNTAIN where @mount = mountainid) 
  and
  If not exists (select skilllevel from SKILLLEVEL where @skill = SkillLevel)
  and 
  If not exists (select snowmakerID from SNOWMAKER where @snow = SnowMakerID)
  and
  If not exists (select liftID from LIFT where @lift = LiftID)
  BEGIN
      INSERT INTO TRAIL (MountainID, SkillLevel, SnowMakerID, LiftID, TOpen, AmountRealSnow, AmountFakeSnow, TrailName)
      values
      (@Mount, @Skill, @Snow, @Lift, @Open, @AmountReal, @AmountFake, @Name)
      Return @@Identity 
  END
  END
  </code></pre>
  
  <p>The columns I need to make sure exist are the mountainid in the mountain table, the skilllevel in the SKILLLEVEL table, the snowmakerid in the snowmakertable and the liftID in the lift table. </p>
  
  <p>If you need any more information please let me know! Please help if you can!</p>