Hi, I have a procedure that does MERGE. however I have new changes, please see below, these are some of the variables I have:
CREATE PROCEDURE procedure_name @procedureNameID OUT @MemberID @StudentID @ErrorCode OUT @ErrorDesc OUT AS BEGIN
BEGIN TRY
END TRY
BEGIN CATCH END CATCH
END
I am getting Member and Student ID as parameters, but I want to Test them first to see if they exist in my tables, if they don't, I want the procedure and I want it return a message that Member or Student ID does not exist. I have to test MemerID alone first; IF( SELECT MemberID FROM database.dbo.view_MyView WHERE MemberID = @MemberID ) IS NULL
If MemberID is null, I have to throw an error and return the @MemberID with a message back to the users that the @MemberID they sent doesn't exist, the same with StudentID. I've been trying RAISERROR but I don't been to get it right, instead it runs the whole proc. please help.
|