Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations MikeeOK on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Default value 1

Status
Not open for further replies.

GrigoreDolghin

Programmer
Oct 23, 2000
167
RO
Hello

I've designed a table in MSDE and one of columns is DateTime type. Is there a way to automatically update the DateTime field, inserting server's current date and time, at every table's update?

I'm not considering to switch to TimeStamp datatype.

Thank you. Grigore Dolghin
Class Software
Bucharest, Romania
 
Yes, put default value as GetDate().

Ion cel de peste tot :) John Fill
1c.bmp


ivfmd@mail.md
 
Ion,

We had some problems in the past, and it seems there are still between us.

Let me write again my sentence:

Is there a way to automatically update the DateTime field, inserting server's current date and time, at every table's update?

GetDate() will take care only for the new inserted record (as I'm positive you know this, but for some reason you don't give the correct answer).

I need the datetime at the UPDATE record, not INSERT record. Is there a way to say better this? Let me switch to Romanian, then:

Ce mi-ai zis stiam, ca nu-s tampit. Daca ai vreo solutie, o zici, daca vrei; dar daca nu, atunci mai slabeste-ma. Ok?

--------------------------------------

Anyone can help me? Is there a way to set a trigger for update? Grigore Dolghin
Class Software
Bucharest, Romania
 
Hi Grigore.
You can write a trigger like this:

create trigger tr_datestamp on <table_name>
for update
as
update <table_name>
set datestamp = getdate()
where <pk_id> in (select <pk_id> from inserted)

 
Redlam,

Thank you very much. This is exactly what I need.

Grigore Dolghin
Class Software
Bucharest, Romania
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top