USE TEMPDB
GO

CREATE TABLE Customers
(
  customerid CHAR(5) NOT NULL,
  /* other columns */
  CONSTRAINT PK_Customers PRIMARY KEY(customerid)
)
GO

INSERT INTO Customers VALUES('MOE')
INSERT INTO Customers VALUES('CURLY')
INSERT INTO Customers VALUES('LARRY')
INSERT INTO Customers VALUES('SHEMP')
GO

CREATE TABLE Orders
(
  orderid    INT      NOT NULL,
  customerid CHAR(5)  NULL DEFAULT('SHEMP'),
  orderdate  DATETIME NOT NULL,
  CONSTRAINT PK_Orders PRIMARY KEY(orderid),
  CONSTRAINT FK_Orders_Customers
    FOREIGN KEY(customerid)
    REFERENCES Customers(customerid)
      ON DELETE SET NULL
      ON UPDATE SET DEFAULT
)
INSERT INTO Orders VALUES(1, 'MOE', '20051010')
INSERT INTO Orders VALUES(2, 'MOE', '20051011')
INSERT INTO Orders VALUES(3, 'CURLY', '20051015')
INSERT INTO Orders VALUES(4, 'CURLY', '20051015')
INSERT INTO Orders VALUES(5, 'LARRY', '20051020')
GO

SELECT * FROM Orders

DELETE FROM Customers
WHERE customerid = 'MOE'
UPDATE Customers
  SET customerid = 'CURLY'
WHERE customerid = 'JOE'
GO

SELECT * FROM Orders
GO

-- the UPDATE will cause an error 
-- because you've deleted the default customer
DELETE FROM Customers
WHERE customerid = 'SHEMP'
UPDATE Customers
  SET customerid = 'FRED'
WHERE customerid = 'LARRY'
GO