August 14, 2009 at 7:50 am
Hi everyone, been awhile... lol...
ive created an after delete trigger on a table that i need to track. Someone or something is deleting records off this table. my trigger is already in place but my question is...
what's the SQL to get the username that's deleting the row?
August 14, 2009 at 8:07 am
user_name()
suser_sname()
Depends on what you want.
August 14, 2009 at 8:08 am
There are a few you could use:
I'd probably go with SYSTEM_USER.
Jack Corbett
Consultant - Straight Path Solutions
Check out these links on how to get faster and more accurate answers:
Forum Etiquette: How to post data/code on a forum to get the best help
Need an Answer? Actually, No ... You Need a Question
August 14, 2009 at 8:26 am
A much easier way is to create a WMI alert on it and insert the values in a table .
Let me know if you need me to type in the Query here ..
Regards
Abhay
Abhay Chaudhary
Sr.DBA (MCITP/MCTS :SQL Server 2005/2008 ,OCP 9i)
August 14, 2009 at 8:32 am
hi_abhay78 (8/14/2009)
A much easier way is to create a WMI alert on it and insert the values in a table .Let me know if you need me to type in the Query here ..
Regards
Abhay
I'd be interested in seeing how you'd track deletes using a WMI query and an alert, so please share the code.
Jack Corbett
Consultant - Straight Path Solutions
Check out these links on how to get faster and more accurate answers:
Forum Etiquette: How to post data/code on a forum to get the best help
Need an Answer? Actually, No ... You Need a Question
August 14, 2009 at 9:40 am
Give me time till Monday (as its weekend) and your email address as I am on a location where there is no SQL Server (preparing documents to travel to US which is due in 2 months :D) .....
Will do it for you ....
Regards
Abhay
Abhay Chaudhary
Sr.DBA (MCITP/MCTS :SQL Server 2005/2008 ,OCP 9i)
August 14, 2009 at 10:00 am
Feel free to use to DM with the code as an attachment. I prefer not to give out my email address on the forums.
Jack Corbett
Consultant - Straight Path Solutions
Check out these links on how to get faster and more accurate answers:
Forum Etiquette: How to post data/code on a forum to get the best help
Need an Answer? Actually, No ... You Need a Question
August 14, 2009 at 10:02 am
hi_abhay78 (8/14/2009)
A much easier way is to create a WMI alert on it and insert the values in a table .Let me know if you need me to type in the Query here ..
Regards
Abhay
While you may be able to do this, I'm not sure an easier way is to use a WMI alert. I've played with WMI a little and it isn't as simple as using a built-in function within a trigger.
Jack Corbett
Consultant - Straight Path Solutions
Check out these links on how to get faster and more accurate answers:
Forum Etiquette: How to post data/code on a forum to get the best help
Need an Answer? Actually, No ... You Need a Question
August 14, 2009 at 10:12 am
hi_abhay78 (8/14/2009)
Give me time till Monday (as its weekend) and your email address as I am on a location where there is no SQL Server (preparing documents to travel to US which is due in 2 months :D) .....Will do it for you ....
Regards
Abhay
Actually, you should probably post the code publicly here as I am sure others would be interested in seeing at well.
August 14, 2009 at 10:21 am
I'm not sure WMI is easier, or even more foolproof. We had issues in W2K with the service. Not sure about W2K3 or @2k8
However, I agree that posting the code here would be great.
Viewing 10 posts - 1 through 9 (of 9 total)
You must be logged in to reply to this topic. Login to reply