Initial commit
This commit is contained in:
@@ -0,0 +1,22 @@
|
||||
USE [Database]
|
||||
|
||||
IF OBJECT_ID('[Tables].[trg_insert_product_values]', 'TR') IS NOT NULL
|
||||
DROP TRIGGER [Tables].[trg_insert_product_values];
|
||||
GO
|
||||
CREATE TRIGGER [Tables].[trg_insert_product_values] ON [Tables].[product_values] AFTER INSERT
|
||||
AS
|
||||
IF EXISTS(
|
||||
SELECT *
|
||||
FROM (
|
||||
SELECT [i].[value], COUNT(*) AS [count]
|
||||
FROM [Tables].[product_values] AS [PV]
|
||||
JOIN [inserted] AS [i]
|
||||
ON [i].[id] = [PV].[product_id]
|
||||
) AS [values]
|
||||
WHERE [count] > 1
|
||||
)
|
||||
BEGIN
|
||||
ROLLBACK TRANSACTION;
|
||||
RETURN;
|
||||
END
|
||||
GO
|
||||
Reference in New Issue
Block a user