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.

 All Forums
 SQL Server 2005 Forums
 Transact-SQL (2005)
 adding to a trigger

Author  Topic 

cwfontan
Yak Posting Veteran

87 Posts

Posted - 2009-11-13 : 12:47:33
trigger
-- Audit trigger-------
ALTER TRIGGER [dbo].[LogSQL]
ON [dbo].[M8_Customers]
AFTER INSERT, UPDATE, DELETE
AS
INSERT INTO dbo.PB_Logs (language_event, parameters, event_info)
EXEC('DBCC INPUTBUFFER(@@SPID);');
-----------------------

I want to add the following to the trigger and have the results inserted into column appName
SELECT program_name FROM sys.dm_exec_sessions WHERE session_id = @@SPID

X002548
Not Just a Number

15586 Posts

Posted - 2009-11-13 : 13:07:14
how do you see a correlation between that DBCC Command and a trigger on a table?

It doesn't have to be the last command that acted on a table, right?



Brett

8-)

Hint: Want your questions answered fast? Follow the direction in this link
http://weblogs.sqlteam.com/brettk/archive/2005/05/25/5276.aspx

Add yourself!
http://www.frappr.com/sqlteam



Go to Top of Page

X002548
Not Just a Number

15586 Posts

Posted - 2009-11-13 : 13:09:13
quote:
Originally posted by cwfontan
SELECT program_name FROM sys.dm_exec_sessions WHERE session_id = @@SPID




and that would be meaningless in a trigger anyway



Brett

8-)

Hint: Want your questions answered fast? Follow the direction in this link
http://weblogs.sqlteam.com/brettk/archive/2005/05/25/5276.aspx

Add yourself!
http://www.frappr.com/sqlteam



Go to Top of Page

cwfontan
Yak Posting Veteran

87 Posts

Posted - 2009-11-13 : 14:14:07
i actually used the App_Name() fucntion.. very nice
Go to Top of Page

cwfontan
Yak Posting Veteran

87 Posts

Posted - 2009-11-13 : 15:41:15
-- Audit trigger
ALTER TRIGGER [dbo].[LogSQL]
ON [dbo].[M8_Customers]
AFTER INSERT, UPDATE, DELETE
AS
INSERT INTO dbo.PB_Logs (language_event, parameters, event_info,FormName)
EXEC('DBCC INPUTBUFFER(@@SPID);');


--I WANT TO ADD THIS TO THE FORMNAME COLUMN???
Values(APP_NAME())
Go to Top of Page
   

- Advertisement -