Amudhan Kuppan

Amudhan Kuppan

  • NA
  • 378
  • 30.2k

i have one doubt for trigger

Mar 8 2018 10:22 PM
hi 
  
anyone help me i cant understand this task 
 
i will send requirement 
 
Create student hisotry table
so when ever update or insert record in student table its marks in this table
table structure
id
StudentID (id of student table)
ColumnName
OldValue
NewValue
UpdatedDatetime
 
please create trigger for this
i want to show history for student table what ever changes are done in student table should be show in table.
when i am change name of any record
i.e Ram to Raju
than insert data with that record id, Column Name='Name' old value ='Ram' New value ='Raju'
 
SELECT [ID]
,[StudentID]
,[ColumnName]
,[OldValue]
,[NewValue]
,[Updateddatetime]
FROM [IT TEST].[dbo].[StudentHistory]
this is my student history record table structure
SELECT [ID]
,[FirstName]
,[LastName]
,[DateOfBirth]
,[Fathername]
,[MotherName]
,[Gender]
,[Height]
,[Weight]
FROM [IT TEST].[dbo].[Student]
 
this is my table structure for student 

Answers (22)