Simple trigger that Delete records from particular table.
Situation : There is one field type is single/joint if user select joint one field enter joint account name and if single then that fields disapears so now if user change joint type to single then joint account name is deleted form database using this trigger.
Answer :
CREATE TRIGGER Tr_Name_UpdateRecordTable
On Table_name
FOR UPDATE,insert AS
declare @Id int
declare @Type int
select @Id=Id from inserted
select @Type=Type from inserted
// @Type=1 mean single else joint
IF @Type=1
BEGIN
Update Table_name set JointAccountFirstName='' ,JointAccountMiddleName='' ,
JointAccountLastName='' where Id=@Id
END
1 comment:
its very nice
Post a Comment