Note that there are some explanatory texts on larger screens.

plurals
  1. POInsert into table values only if one field value does not exist already
    primarykey
    data
    text
    <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>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload