Hi Guys,I want update time whenver update existing column
Loading
Hi Guys,I want update time whenver update existing column
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Rajanikant HawaldarPosted Jul 10, 2022, 2:24 PM
Jignesh KumarPosted Jul 10, 2022, 12:49 PM
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