-- Oefening 1 CREATE PROCEDURE NewCustomer1 @cust_id int, @cust_name CHAR(50) AS INSERT INTO Customers(cust_id, cust_name) VALUES (@cust_id, @cust_name) Execute NewCustomer1 1000000006, 'Karel de Roo' -- Oefening 2 CREATE PROCEDURE NewCustomer2 @cust_name CHAR(50) AS DECLARE @cust_id int SELECT @cust_id=max(cust_id) FROM Customers SELECT @cust_id = @cust_id + 1 INSERT INTO Customers(cust_id, cust_name) VALUES (@cust_id, @cust_name) Execute NewCustomer2 'Floor Boomsa'; -- Oefening 3 CREATE PROCEDURE NewOrder @cust_id CHAR(10) AS DECLARE @order_num int SELECT @order_num=max(order_num) FROM Orders SELECT @order_num=@order_num+1 INSERT INTO Orders(order_num, order_date, cust_id) VALUES(@order_num, GETDATE(), @cust_id) Execute NewOrder 1000000007;
Download hier het bestand.