Dear Sir, I have written a INSERT Trigger to insert records from Table1(Col1,Col2) to Table2 (Col1,Col2). I want to prevent duplicate value to insert into the column Col1 in the Table2. How Can I do this ? Thanks.
I want to do this thru Code. I want to check that a.no_of_item is already exist in the column no_of_item of the pur_gi_header table. Original Code given below CREATE trigger [sub_contracting_order] on dbo.pur_gi_header for insert as BEGIN If EXISTS(select 'X' from inserted a where a.po_category = 'SER' AND a.no_of_item = '0' ) BEGIN EXEC pur_msg_rtr '02999200052', 'For Service Orders, Machine No is Mandatory' , 'I' END END