I have these two stored procedures that work as expected.
here ================
Create PROCEDURE [dbo].[GetCustomerIDFromCustomerDeviceByGUID]
-- Add the parameters for the stored procedure here
@gUID uniqueidentifier
AS
BEGIN
SET NOCOUNT ON;
DECLARE @customerID int;
SELECT @customerID = 0;
SELECT @customerID = [Jahasma.Customer.Device].[CustomerID]
FROM [Jahasma.Customer.Device]
WHERE ([Jahasma.Customer.Device].[GUID] = @gUID);
SELECT @customerID as 'CustomerID'
END
and here ====================
Create PROCEDURE [dbo].[Jahasma_GetCustomerInjuryByCustomerID]
@customerID smallint
AS
BEGIN
SET NOCOUNT ON
SELECT
[jahasma.Customer.Injury].[InjuryID] AS 'InjuryID',
[jahasma.Customer.Injury].[InjuryDescription] AS 'InjuryDescription',
[jahasma.Customer.Injury].[LastUpdateUTC] AS 'LastUpdateUTC'
FROM [dbo].[Jahasma.Customer.Injury] [jahasma.Customer.Injury]
WHERE [jahasma.Customer.Injury].[CustomerID]=@customerID
SET NOCOUNT OFF
END
Can someone please help me write a Third Procedure that will execute
the two procedures I have above
I want to call the first SP and get back the CustomerID. Then call the
second SP and return the recordset.
It should go something like this....
CREATE PROCEDURE [dbo].[Jahasma_GetCustomerInjuryByCustomerDeviceGuid]
@gUID uniqueidentifier
AS
BEGIN
SET NOCOUNT ON
-- =============================================
-- Create a customerID variable
-- Call Jahasma_GetCustomerIDFromCustomerDeviceByGUID
-- and remember the CustomerID
-- =============================================
DECLARE @customerID smallint
@customerID = EXECUTE
[dbo].[Jahasma_GetCustomerIDFromCustomerDeviceByGUID]
@gUID = @gUID;
-- =============================================
-- Call Jahasma_GetCustomerInjuryByCustomerID
-- using the Customer ID and the parameter
-- =============================================
EXECUTE [dbo].[Jahasma_GetCustomerInjuryByCustomerID]
@customerID = @customerID;
SET NOCOUNT OFF
END