Hi Guys,I want update time whenver update existing column
Update time whenver update existing column
2 Answers
Know the answer? Post it. Somebody with the same question will find it here.
Hi Guys,I want update time whenver update existing column
Know the answer? Post it. Somebody with the same question will find it here.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend5days leftRegister
Jignesh KumarRank #91 · 22.9K reputationPosted Jul 10, 2022, 8:49 AM EDT
Hi Dharma,
If you wish to se only updated date then you can create trigger.
If you are using store procedure then you can set yout modified coulmn,
UPDATE Employee
SET ModifiedDate=GetDate()
WHERE Id= 'EmployeeId'
If you are using Entity Framework then,
using (EFContext db = new EFContext())
{
var emp = db.Employee.Where(d => d.Name == "Test").First();
emp.ModifiedDate = DateTime.UtcNow;
db.SaveChanges();
}
or you can create trigger,
https://stackoverflow.com/questions/21493178/need-a-datetime-column-in-sql-server-that-automatically-updates-when-the-record
Rajanikant HawaldarRank #110 · 20.2K reputationPosted Jul 10, 2022, 10:24 AM EDT