- Jul 18, 2002
- 1,655
- 1
- 81
I have a table, TABLE_A.
TABLE_A has 3 fields. PK (auto, identity), Name(varchar(50)), and Date_Created (datetime).
When I insert a row into TABLE_A, PK is automatically generated. Name is passed in via a variable in a stored procedure (basic insert statement).
I would like a trigger to automatically fill in the current date time into the Date_Created field.
Here is what I have so far:
CREATE TRIGGER INSERT_TABLE_A
on TABLE_A
for INSERT AS
DECLARE
@NOW DateTime
set @NOW = getdate()
This is where I get confused....how do I insert the current date time into the newly created record?
Thanks in advance
TABLE_A has 3 fields. PK (auto, identity), Name(varchar(50)), and Date_Created (datetime).
When I insert a row into TABLE_A, PK is automatically generated. Name is passed in via a variable in a stored procedure (basic insert statement).
I would like a trigger to automatically fill in the current date time into the Date_Created field.
Here is what I have so far:
CREATE TRIGGER INSERT_TABLE_A
on TABLE_A
for INSERT AS
DECLARE
@NOW DateTime
set @NOW = getdate()
This is where I get confused....how do I insert the current date time into the newly created record?
Thanks in advance
