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 |
|
sqlneofito
Starting Member
16 Posts |
Posted - 2010-04-05 : 18:49:46
|
I need to run this INSERT trigger on an DErrorLog table that counts the number of times the ErrorNumber that is currently being inserted already exists in the table.. with an output to the screen that says "The error: (errornumber) has ocurred X times before"It should be easy but I just can't see the light.Thank you for any suggestions.This is what I have so far create trigger InsTriggErrLog on DErrorLogafter insertasDeclare @t intInserted.ErrorNumberIF exists (select I.ErrorNumber from Inserted as I inner join DErrorLog as D on I.ErrorNumber = D.ErrorNumber)set @t = @@ROWCOUNT ---print 'This error:'; @e 'error has ocurred'; @t-1, 'number of times in the past'print 'number of times in the past' + convert(varchar(25), @t)--print 'number of times in the past' + convert(varchar(25), @e) |
|
|
tkizer
Almighty SQL Goddess
38200 Posts |
|
|
sqlneofito
Starting Member
16 Posts |
Posted - 2010-04-05 : 19:26:58
|
| Hello Tara, thank you for your help, but, where do I declare the value of 'select count' to print the messageThank you again!! |
 |
|
|
tkizer
Almighty SQL Goddess
38200 Posts |
|
|
sqlneofito
Starting Member
16 Posts |
Posted - 2010-04-05 : 20:23:54
|
| Tara you save my day again!! ..thank you very much!! |
 |
|
|
tkizer
Almighty SQL Goddess
38200 Posts |
|
|
|
|
|