title: Insert into table values only if one field value does not exist already
body: <p>I want to insert into table only when field_tag value which is not exist. I want to check prior to insert into the table..if the Receipt exist under the same field_tag value before. If not exist, then only i want to insert. I am using sql server 2008 </p>
  
  <pre><code>INSERT INTO [INVENTORY].[TBL_RECEIPTS]
             ([TicketNbr]
         ,[RevisionNbr]
             ,[Location_ID]
             ,[ContractNumber]
             ,[Storage_ID]
         ,[VarietyID]
             ,[GrossWeight]
             ,[TareWeight]
             ,[Carrier]
             ,[Receipt_date]
             ,[Last_update]
             ,[Inv_weight]
         ,[SAPBatch]
         ,[MoistureFactor]
         ,[Load_Harvested]
         ,[FIELDID]
         ,[GROWER_LOAD_NBR]
         ,[HARVEST_NBR]
         ,[TRACE_WORMS]
         ,[COR_CERT]
         ,[GFF_DEST]
  ---    ,[GFF_CONTRACT]
         ,[CAB_ID]
         ,[sOURCE]
         ,[CREATED_BY]
         ,[TOTALBONUSES]
         ,[PIDNUMBER] 
         ,[CARRIERVENDORID]
         ,[HAUL_ZONE]
         ,[FIELD_Tag]
         ,[Station]
         ,[COUNTY]
         ,[GradeDate]
         ,[Load_Received]
         ,[Load_Processed]
  
  )
       VALUES
             (@CERT
        ,@RevisionNbr
             ,@Location_ID
             ,@ContractNUmber
             ,@Storage_ID
         ,@VarietyID
             ,@Gross_Weight
             ,@TareWeight
             ,@CarrierName
             ,@receipt_date
             ,Getdate()
             ,@Inv_weight
         ,@receiptbATCHnbr
         ,@DockageWeight
         ,@HARVEST_DT
         ,@FIELDID
         ,@GROWER_LOAD_NBR
         ,@HARVEST_NUMBER
         ,@TRACE_WORMS    
         ,@COR_CERT
         ,@GFF_DEST
  ---    ,@CONTRACT
         ,@CAB_ID
         ,'I'
         ,'Scale Interface'
         ,0
         ,@ContractPIDNumber
         ,@CARRIERID
         ,@HAUL_ZONE
         ,@FIELD_TAG
         ,@STATION
         ,@COUNTY
         ,@GRADE_DT
         ,@Arrival_dt
         ,@current_Date
  )
  </code></pre>
  
  <p>I did like this : </p>
  
  <pre><code>insert into yourtable
  (field1, field2, etc)
  select value1, value2, etc
  where not exists
  ( SELECT * FROM [INVENTORY].[TBL_RECEIPTS] WHERE Field_Tag = @FIELD_TAG)
  </code></pre>
  
  <p>How to print the errors, I want to do error handling on this. If duplicate is there..it should print message.</p>