File tree Expand file tree Collapse file tree
samples/containers/unit-testing/tsqlt-docker/source Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ -- -----------------------------------------------------------------------
2+ -- Demo: SQL Server CI/CD -
3+ -- -
4+ -- Script: Create trigger TR_Product_SafetyStockLevel -
5+ -- Author: Sergio Govoni -
6+ -- Notes: -- -
7+ -- -----------------------------------------------------------------------
8+
9+ USE [AdventureWorks2017];
10+ GO
11+
12+ CREATE OR ALTER TRIGGER Production .TR_Product_SafetyStockLevel
13+ ON Production .Product
14+ AFTER INSERT AS
15+ BEGIN
16+ /*
17+ Avoid to insert products with safety stock level lower than 10!
18+ */
19+ DECLARE @SafetyStockLevel SMALLINT ;
20+
21+ SELECT
22+ @SafetyStockLevel = SafetyStockLevel
23+ FROM
24+ inserted;
25+
26+ IF (@SafetyStockLevel < 10 )
27+ BEGIN
28+ -- Error!!
29+ EXEC Production .usp_Raiserror_SafetyStockLevel
30+ @Message = ' Safety stock level cannot be lower than 10!' ;
31+ END ;
32+ END ;
33+ GO
You can’t perform that action at this time.
0 commit comments