Thursday, September 01, 2011

Inserted and Deleted table in sql server

create table Billings (
BankerID INTEGER,
BillingNumber INTEGER,
BillingDate datetime,
BillingTotal INTEGER,
TermsID INTEGER,
BillingDueDate datetime ,
PaymentTotal INTEGER,
CreditTotal INTEGER
;
GO

INSERT INTO Billings VALUES (1, 1, '2005-01-22', 165, 1,'2005-04-22',123,321);
GO

(1 rows affected)
INSERT INTO Billings VALUES (2, 2, '2001-02-21', 165, 1,'2002-02-22',123,321.);
GO

(1 rows affected)

CREATE TRIGGER trStudentsEcho
ON Billings
FOR UPDATE, INSERT, DELETE
AS
SELECT * FROM inserted
SELECT * FROM deleted
GO

drop trigger trStudentsEcho;
GO

drop table Billings;
GO

No comments: