Author |
Topic |
seyha_moth
Yak Posting Veteran
74 Posts |
Posted - 2007-05-17 : 03:46:06
|
Dear sir or madamI want to create trigger to get IP address,computer name and Date of user when they insert,update or delete data in table.I look forward to hearing from youThank you in advance!seyha moth |
|
khtan
In (Som, Ni, Yak)
17689 Posts |
Posted - 2007-05-17 : 03:47:55
|
IP address is not available.computer name : host_name()date : getdate() KH |
 |
|
seyha_moth
Yak Posting Veteran
74 Posts |
Posted - 2007-05-17 : 03:51:32
|
I write the following triggerCREATE TRIGGER [trX_ExamScore]ON [dbo].[tblX_ExamScore]FOR UPDATEAS INSERT INTO tblX_ExamScoreUpdated(ExamScoreID,SubjectExID,ScoreTypeID,Score,UpdateDate,Comment) Select del.ExamScoreID,del.SubjectExID,del.ScoreTypeID,Score,GetDate(),'Old'+host_name FROM DELETED del INSERT INTO tblX_ExamScoreUpdated(ExamScoreID,SubjectExID,ScoreTypeID,Score,UpdateDate,Comment) Select ins.ExamScoreID,ins.SubjectExID,ins.ScoreTypeID,Score,GetDate(),'Update'+hostname FROM INSERTED insbut they made errorMsg 207, Level 16, State 3, Procedure trX_ExamScore, Line 9Invalid column name 'host_name'.Can you help me?seyha moth |
 |
|
khtan
In (Som, Ni, Yak)
17689 Posts |
Posted - 2007-05-17 : 03:54:39
|
it is host_name() KH |
 |
|
seyha_moth
Yak Posting Veteran
74 Posts |
Posted - 2007-05-17 : 03:59:22
|
I corrected it from hostname to host_name but it still make the same errorseyha moth |
 |
|
khtan
In (Som, Ni, Yak)
17689 Posts |
Posted - 2007-05-17 : 04:01:46
|
[code]CREATE TRIGGER [trX_ExamScore]ON [dbo].[tblX_ExamScore]FOR UPDATEASINSERT INTO tblX_ExamScoreUpdated(ExamScoreID,SubjectExID,ScoreTypeID,Score,UpdateDate,Comment) Select del.ExamScoreID,del.SubjectExID,del.ScoreTypeID,Score,GetDate(),'Old'+host_name() FROM DELETED delINSERT INTO tblX_ExamScoreUpdated(ExamScoreID,SubjectExID,ScoreTypeID,Score,UpdateDate,Comment) Select ins.ExamScoreID,ins.SubjectExID,ins.ScoreTypeID,Score,GetDate(),'Update'+ host_name()FROM INSERTED ins[/code] KH |
 |
|
seyha_moth
Yak Posting Veteran
74 Posts |
Posted - 2007-05-17 : 04:05:19
|
Thank you for your reply.Now, I can solve it with your help.seyha moth |
 |
|
|
|
|