I want to use CASE statement something like below code or any other suggestion to implement said scenario.
I will be using this in some SP where @UpdateStatus I will be getting as input parameter.
Please suggest.
DECLARE @UpdateStatus nvarchar(20)
SET @UpdateStatus='P'
CASE
WHEN @UpdateStatus='P' THEN
BEGIN
BEGIN TRAN
Print 'A' --Update some table
COMMIT
END
WHEN @UpdateStatus='F' THEN
BEGIN
BEGIN TRAN
Print 'B' --Update some table
COMMIT
END
END
Use IF Else Statement to handle different value
DECLARE @UpdateStatus nvarchar(20)
SET @UpdateStatus='P'
IF @UpdateStatus='P'
BEGIN
BEGIN TRAN
Print 'A' --Update some table
COMMIT
END
ELSE IF @UpdateStatus='F'
BEGIN
BEGIN TRAN
Print 'B' --Update some table
COMMIT
END
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With