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 |
|
dineshrajan_it
Posting Yak Master
217 Posts |
Posted - 2009-04-27 : 02:48:58
|
| Hi all,How to audit Select statements in sql server 2005. thanks in advanceIam a slow walker but i never walk back |
|
|
svicky9
Posting Yak Master
232 Posts |
Posted - 2009-04-27 : 07:31:23
|
| You need to use profiler to log the events and then export them in a table.It may add to lot of overhead.If the end users are using a procedure something likecreate procedure TEST_SELECTasselect col2 from Table1then you can modify this procedure something like SET NO COUNT ONcreate procedure TEST_SELECTasDeclare @SQL nvarchar(max)Beginset @SQL = 'select col2 from Table'Exec(@sql)Insert into AuditTable(Username,Query) values (@@USERNAME,@SQL)Endhttp://www.sqlserver007.com |
 |
|
|
dineshrajan_it
Posting Yak Master
217 Posts |
Posted - 2009-04-27 : 09:04:58
|
| Hi thanks for reply,i would love using sql profiler. i have stored the profiler data to a table named newtrace. and then iam creating a trigger for that newtrace tableALTER TRIGGER tr_Trace ON TraceTriggerFOR INSERTASDECLARE @INT INTSELECT CAST(TextData AS VARCHAR(MAX)) FROM INSERTEDGOwhen i try to create this trigger i get the errorCannot use text, ntext, or image columns in the 'inserted' and 'deleted' tables.Iam a slow walker but i never walk back |
 |
|
|
|
|
|