Hello, I'm building a stored procedure. This stored procedure needs to insert a record if a record with a specific value does not exist. If the value does exist, I need to update the record. The problem I'm having is determining if a record with the given value exists or not. I am using the following code:
DECLARE @record1ID as char(36)
SET @record1ID = (SELECT TOP 1 ID FROM Person WHERE [Role]='Manager')
DECLARE @record2ID as char(36)
SET @record2ID = (SELECT TOP 1 d.ID FROM Department d WHERE d.[ManagerID]=@record1ID)
-- If @record2ID is set update record, otherwise add record
-- how do I setup this if/else statement?
Thank you!