As Jonas says, Profiler is your best bet (and only an option for SELECT queries). For INSERT, UPDATE, DELETE, the closest you can get without a Profiler might be to look at the input buffer through DBCC INPUTBUFFER(@@SPID) . This will only work for special language events, not for RPC calls, and will only show the first 256 characters of the SQL statement (depending on version, I reckon). Example code (run as dbo):
CREATE TABLE TBL (a int, b varchar(50)) go INSERT INTO TBL SELECT 1,'hello' INSERT INTO TBL SELECT 2,'goodbye' go GRANT SELECT, UPDATE ON TBL TO guest go CREATE TABLE AUDIT ( audittime datetime default(getdate()) , targettable sysname , loginname sysname , spid int , sqltext nvarchar(max)) go CREATE TRIGGER TR_TBL ON TBL FOR INSERT, UPDATE, DELETE AS BEGIN CREATE TABLE
doza Dec 16 '09 at 0:06 2009-12-16 00:06
source share