title: SQL Insert if Values doesn't exist
body: <p>So I need to insert values into a table, but if those values exist I want my script to not insert anything. I have pretty much gotten it solved, but I am stuck at the very end with my insert statement. </p>
  
  <pre><code>DECLARE @billableitemID int;
  set @billableitemid = (select billableitemID from dbo.treatment where 
  @billableitemid=treatment.id)
  set @billableitemID = 256
  
  
  
  CREATE TABLE #MembershipBenefitItem
      ( BenefitID int ,
        BillableItemTypeID int ,
        BillableItemID  int
      )
  
  INSERT INTO #MembershipBenefitItem
      ( BenefitID ,
        BillableItemTypeID ,
        BillableItemID 
      )
  
   VALUES  (23450,1,@billableitemid),
  (57256,1,@billableitemid)
  
  select m.* from #MembershipBenefitItem  AS M
  left join membershipbenefititem AS M1 on m.billableitemid= m1.billableitemid 
  and m.billableitemtypeid= m1.billableitemtypeid 
  and m.benefitid= m1.benefitID
  and M1.billableitemID=@billableitemID and M1.billableitemtypeID=1 and 
  M1.benefitID IN(23450,57256)  
  where M1.ID is null
  
  INSERT INTO MembershipBenefitItem
      ( BenefitID,
        BillableItemTypeID,
        BillableItemID 
      )
  
   select m.BenefitID, m.BillableItemTypeID, m.BillableItemID from 
  #MembershipBenefitItem  AS M
  left join membershipbenefititem AS M1 on m.billableitemid= m1.billableitemid 
   and m.billableitemtypeid= m1.billableitemtypeid 
   and m.benefitid= m1.benefitID
  and M1.billableitemID=@billableitemID and M1.billableitemtypeID=1 and 
  M1.benefitID IN(23450,57256) 
  where M1.ID is null
  
  
  
  DROP TABLE #MembershipBenefitItem
  </code></pre>