How to check if record exists in sql before insert.