“Merge” style operation with literal values?
I have a table containing a student-grade relationship: Student Grade StartDate EndDate 1 1 09/01/2009 NULL 2 2 09/01/2010 NULL 2 1 09/01/2009 06/15/2010 I am trying to write a stored procedure that takes Student , Grade , and StartDate , and I would like it to check to make sure these values are not duplicates insert the record if it's not a duplicate if there is an existing student record, and it has a EndDate = NULL , then update that record with the StartDate of the new record. For instance, if I call the procedure and pass in 1 , 2 , 09/01/2010 , I'd like to end up with: Student Grade