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 wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Update Field with another field

Status
Not open for further replies.

jnavarro

Programmer
Dec 1, 2003
89
US
I have two fields in my table, one field is updated when the employee is hired. The second field is the term date, which this field is null until the employee has resigned their position. I would like to default this field with the employee's hiredate. How do I do that?

I have try default value but I cannot get that to work. Any ideas?

Thanks in advance
JCN
 
UPDATE myTable SET termDate=hireDate WHERE termDate IS NULL

Programming today is a race between software engineers striving to build better and bigger idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning. - Rick Cook (No, I'm not Rick)

zen.gif
 
Default value is only effective when the record is created you could acheive what you want by creating an update trigger so when the hire date is updated the trigger causes the term field to be updated with the hire date

Savil
 
If you want to be able to do it when you are inserting a new record, you could use a trigger or simply alter your input statement - I thought you were trying to update old data...

Programming today is a race between software engineers striving to build better and bigger idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning. - Rick Cook (No, I'm not Rick)

zen.gif
 
How would you create a trigger to do this task. I am new to the SQL enviorment.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top