I have two stored procs that work together, the first one gathers the IDs from the user input and the other one takes the ids and inserts them into the db
The first SP never seems to call the second SP, how can I make this work?
First SP
Second SPCode:ALTER PROCEDURE dbo.spNewTicket @tTicketID int, @BusinessUnitName nvarchar(50), @ServiceName nvarchar(50), @ResponsibilityOwnerName nvarchar(50), @ClassificationName nvarchar(50) AS DECLARE @BusUnitID Int DECLARE @ServID Int DECLARE @RespID Int DECLARE @ClassID Int SET @BusUnitID = (select BusinessUnitID from tblBusinessUnit where BusinessUnitName=@BusinessUnitName) SET @ServID = (select ServiceID from tblService where ServiceName=@ServiceName) SET @RespID = (select ResponsibilityOwnerID from tblResponsibilityOwner where ResponsibilityOwnerName=@ResponsibilityOwnerName) SET @ClassID = (select ClassificationID from tblClassification WHERE ClassificationName=@ClassificationName) EXEC spAddTicketDetail @TicketID=@tTicketID, @BusinessUnitID=@BusUnitID, @ServiceID=@ServID, @ResponsibilityOwnerID=@RespID, @ClassificationID=@ClassID RETURN
Code:ALTER PROCEDURE [dbo].[spAddTicketDetail] @TicketID int OutPut, @BusinessUnitID int, @ServiceID int, @ClassificationID int, @ResponsibilityOwnerID int AS BEGIN TRY IF NOT @TicketID = (SELECT TicketID from [dbo].[tblTicketDetail] WHERE TicketID = @TicketID) INSERT INTO [dbo].[tblTicketDetail] VALUES (@TicketID, @BusinessUnitID, @ServiceID, @ResponsibilityOwnerID, @ClassificationID, GetDate()) END TRY BEGIN CATCH SELECT ERROR_NUMBER() END CATCH RETURN




Reply With Quote