hi,
The below is the sql statement that inserts the record if only the record is not exists in table.. but the statement i written is inserting multiple times the same record... please help me to resolve my problem..
Hide Copy Code
INSERT INTO TableName(AccountNo,Customer,ContactNo) select 'AP1234','Saketh','984822338' FROM TableName WHERE NOT EXISTS(Select * From TableName Where AccountNo='AP1234');

Upendra Pratap ShahiPosted May 27, 2015, 8:06 AM
CHAITANYA KIRAN KASANIPosted May 27, 2015, 8:04 AM
Upendra Pratap ShahiPosted May 27, 2015, 7:50 AM
CHAITANYA KIRAN KASANIPosted May 27, 2015, 7:42 AM
I Have To add DISTINCT to select command
now it Inserting The Record Single Time Only,
INSERT INTO TableName(AccountNo,Customer,ContactNo) select DISTINCT 'AP1234','Saketh','984822338' FROM TableName WHERE NOT EXISTS(Select DISTINCT AccountNo From TableName Where AccountNo='AP1234');
Upendra Pratap ShahiPosted May 27, 2015, 5:08 AM
Dipankar BiswasPosted May 27, 2015, 5:01 AM