title: Can I use "if not exists" to insert a row if the row is not already present in sql server?
body: <pre><code>insert into Attributes (Id, Disabled, AttributeValue) 
  values (@id, @disabled, @attr_value)
  if not exists
  (
  select * from Attributes
  where 
  Id = @id
  )
  </code></pre>
  
  <ul>
  <li>Not sure, if this is a valid query. </li>
  <li>I have seen people use where not exists. What is the difference and how to use where not exists? When I put <em>where not exists</em>, it is saying "Incorrect syntax near where."</li>
  </ul>
  
  <p>I checked these question as well. But, it doesn't seem to have query to insert using <em>if not exists</em>. 
  <a href="https://stackoverflow.com/questions/3407857/only-inserting-a-row-if-its-not-already-there">Only inserting a row if it&#39;s not already there</a> and 
  <a href="https://stackoverflow.com/questions/2290792/sql-conditional-insert-if-row-doesnt-already-exist">sql conditional insert if row doesn&#39;t already exist</a></p>
  
  <ul>
  <li>Am I missing something? Should I only use <em>where not exists</em>?</li>
  </ul>