1>
2> CREATE TRIGGER OrderHasCustomer
3> ON Orders
4> FOR INSERT, UPDATE
5> AS
6> IF EXISTS
7> (
8> SELECT 'True'
9> FROM Inserted i
10> LEFT JOIN Customers c
11> ON i.CustomerID = c.CustomerID
12> WHERE c.CustomerID IS NULL
13> )
14> BEGIN
15> RAISERROR('Order Must Have Valid CustomerID',16,1)
16> ROLLBACK TRAN
17> END
18> GO
2> CREATE TRIGGER OrderHasCustomer
3> ON Orders
4> FOR INSERT, UPDATE
5> AS
6> IF EXISTS
7> (
8> SELECT 'True'
9> FROM Inserted i
10> LEFT JOIN Customers c
11> ON i.CustomerID = c.CustomerID
12> WHERE c.CustomerID IS NULL
13> )
14> BEGIN
15> RAISERROR('Order Must Have Valid CustomerID',16,1)
16> ROLLBACK TRAN
17> END
18> GO
No comments:
Post a Comment