Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
AskSQLTeam
Ask SQLTeam Question
0 Posts |
Posted - 2000-09-20 : 18:27:46
|
Macy writes "Below are a few statements from a trigger I'm trying to create on a table that updates my ActivityLog table with old info and new info of a field(s) when the field(s) in the table gets updated. I'm trying to create a generic trigger that can be used on any table without having to use actual column names (ie. @ColName is already determined via another routine). I've come to a point where I am really really stuck and need help. My question in it's simpliest form I could possibly get it in is how do I write a statement to properly execute my example select statement shown in *** below. I'm using ms sql server 7 on sp1 with windows nt 4.0 on sp6a.
Any suggestions would be greatly appreciated. If I am going down the wrong path to accomplish what I need to do or if there is an easier way, please let me know...Thank you in advance for your help.
select @iField = 'i.' + @ColName select @dField = 'd.' + @ColName
***select @iFieldValx = (Select + @iField + from inserted i, deleted d where i.id = d.id) ***select @dFieldValx = (Select + @dField + from inserted i, deleted d where i.id=d.id)
if @iFieldValx != @dFieldValx Select @txtDesc = @txtDesc + @ColName + '=' + @iFieldValx + ',' + @dFieldValx + ';' .. .. .. insert the @txtDesc information into my activitylog
"
|
|
|
|
|
|