Menu

[Solved]Test Trigger Code Sql Server Use Myguitarshop Drop Trigger Exists Productsupdate Go Create Q37196863

How do I test this Trigger code for SQL SERVER?

Use MyguitarShop;

DROP TRIGGER IF EXISTS Products_UPDATE;

GO

— Create the trigger

CREATE TRIGGER Products_UPDATE

— Fire trigger by updating the discount percent to 25% forproductID 1 by typing the percent as .25 instead of 25.

ON Products

INSTEAD OF UPDATE

AS

  

BEGIN

DECLARE @DiscountPercent money;

SET @DiscountPercent = (SELECT DiscountPercent FROMProducts);

–IF @DiscountPercent > 0 OR @DiscountPercent <= 1

IF @DiscountPercent BETWEEN 0 and 1

SET @DiscountPercent = @DiscountPercent * 100;

IF @DiscountPercent > 100 OR @DiscountPercent < 0

PRINT ‘ERROR Precentage Should be between 0-100’;

END;

TABLE PRODUCTS:

DiscountPercent(money, not null)

Expert Answer


Answer to How do I test this Trigger code for SQL SERVER? Use MyguitarShop; DROP TRIGGER IF EXISTS Products_UPDATE; GO — Create t… . . .

OR


Leave a Reply

Your email address will not be published. Required fields are marked *