-
I have a stored procedure. I need to get the two select statements into variables. I need to compare both counts and create and error rountine if they do not much. I am enclosing the code, but would also like help on the error handler;
Please assist thanks
CREATE procedure dbo.SpLaLaMonitor
@TestDate smalldatetime= '11/24/00 11:00'
SELECT COUNT (*)as 'what does text here produce?' from dev1.dbo.vw_look_txn Where vendor_err='x' and created_dt>@TestDate
SELECT COUNT (*) as 'what does text here produce?' from Merchant_Order mo join Order_Line ol on ol.Order_ID = mo.Order_ID Where La_To_La=1 and mo.Modified_Date>@TestDate
EXEC dbo.SpLaLaMonitor
--GO
-
You can do something like this:
Code:
CREATE procedure dbo.SpLaLaMonitor
@TestDate smalldatetime= '11/24/00 11:00'
AS
Declare @Result1 int
Declare @Result2 int
SELECT
@Result1 = COUNT(*)
FROM
dev1.dbo.vw_look_txn
WHERE
vendor_err='x' and created_dt > @TestDate
SELECT
@Result2 = COUNT(*)
FROM
Merchant_Order mo join Order_Line ol on ol.Order_ID = mo.Order_ID
WHERE
La_To_La = 1 and mo.Modified_Date > @TestDate
If @Result1 <> @Result2
Begin
Return 1000 --Return any error number you want
End
Else
Begin
Return 0 --Return success number here
End
-
"I wanna be like Mike"
Quote from Volcano when Tommy Lee Jones saves city from Volcano and reroutes it to ocean.
You are awesome thanks!!!