View Single Post

   
  #5 (permalink)  
Old 04-29-2008, 08:26 PM
Plamen Ratchev
 
Posts: n/a
Default Re: capture and save running sql query to database table (for logging)

It is good to note here that DBCC INPUTBUFFER requires the user executing to
be member of the sysadmin fixed server role. One way to handle this is to
specify user or login with sufficient privileges in EXEC (you can use EXEC
AS LOGIN or USER:

INSERT INTO SQLLog (language_event, parameters, event_info)
EXEC('DBCC INPUTBUFFER(@@SPID);') AS LOGIN = 'admin_login';

HTH,

Plamen Ratchev
http://www.SQLStudio.com

Reply With Quote