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');


Dipankar BiswasRank #992 · 2K reputationPosted May 27, 2015, 1:01 AM EDT
Upendra Pratap ShahiRank #329 · 7.5K reputationPosted May 27, 2015, 1:08 AM EDT
CHAITANYA KIRAN KASANIRank #4,018 · 371 reputationPosted May 27, 2015, 3:42 AM EDT
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');
CHAITANYA KIRAN KASANIRank #4,018 · 371 reputationPosted May 27, 2015, 4:04 AM EDT
Upendra Pratap ShahiRank #329 · 7.5K reputationPosted May 27, 2015, 4:06 AM EDT
Upendra Pratap ShahiRank #329 · 7.5K reputationPosted May 27, 2015, 3:50 AM EDT