Exist in-built function in Sql-Server.

Rajesh_Kumar
Posted by Rajesh_Kumar under Sql Server category on | Points: 40 | Views : 400
Exists function is used for checking whether record is there in table or not.It returns true if record is present otherwise returns false.

For Example:-
IF NOT EXISTS (SELECT code_id FROM code_details WHERE code_value ='SUBM') 
BEGIN
INSERT code_details(code_id,code_value,created_by,created_date)
VALUES (1,'SUBM','RAJESH.S',getdate())
END
ELSE PRINT 'Already Exists.';

Comments or Responses

Login to post response