I have this stored procedure:
CREATE PROCEDURE [sp_AddSubjectP2ep]
AS INSERT INTO [SubjectsP2ep]
A very simple stored procedure to add a row of data in a table that has three columns: SubjectID, SubjectNumber and Subject. SubjectID is the primary key/identity column.
However, now the client would like to ensure they are not duplicating either the subject number or subject. How can I rewrite this stored proc to check to see if either the subject number or subject currently exist and if so return a value like -1 or something. Otherwise, insert the data and return a 1.
This is probably pretty normal behaviour (I hope). Are there other approaches I should consider?