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-08-24 : 20:14:27
|
Cory writes "I have created a trigger to update a second table(report) when data is inserted into the first table(dsmclogger). The trick I wish to accomplish is update a column in the report table whos name is 'column' + inserted.eventid. Is this possible?
The query insert dsmclogger(server,appname,date,eventid,logmsg) values('myserver','myapp',getdate(),'0010','my message') should cause the 'column0010' column in the report table (where servername=myserver) to be updated with getdate().
Here is my trigger(so far): ============== CREATE TRIGGER reporter ON dbo.DSMCLogger FOR INSERT AS BEGIN if (SELECT count(*) FROM inserted WHERE eventid IN '0010', '0011'))=1
DECLARE @column_name char(30) SELECT @column_name="column" + inserted.eventid FROM inserted
UPDATE report SET @column_name=inserted.date FROM report, inserted WHERE report.servername=inserted.server END GO =============
Thanks Cory Longman"
|
|
|
|
|
|