Using an AFTER Trigger to Remove Time from a datetime Column : Trigger for after « Trigger « SQL Server / T-SQL Tutorial






5> CREATE TABLE DateTable(
6>   ID        int       NOT NULL IDENTITY (1, 1)
7>                       PRIMARY KEY,
8>   Txt       char (10) NOT NULL,
9>   EntryDate datetime  NOT NULL
10> )
11> GO
1> CREATE TRIGGER t_DateTable ON DateTable AFTER INSERT, UPDATE
2> AS
3> IF @@ROWCOUNT = 0
4>   RETURN
5> IF UPDATE (EntryDate)
6>   UPDATE D
7>   SET
8>     EntryDate = CONVERT (char (10), I.EntryDate, 112)
9>   FROM
10>       inserted  I
11>     JOIN
12>       DateTable D ON D.ID = I.ID
13> GO
1>
2> drop trigger t_DateTable
3> drop table dateTable
4> GO








22.3.Trigger for after
22.3.1.One table with two after-delete triggers
22.3.2.An after-update trigger
22.3.3.Rolling Back in an AFTER Trigger
22.3.4.Using an AFTER Trigger to Remove Time from a datetime Column