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 2000 Forums
 Transact-SQL (2000)
 how can i get the sqlstring that the user used,abo

Author  Topic 

fire1
Starting Member

5 Posts

Posted - 2002-12-23 : 02:41:58
how can i get the sqlstring that the user used,about insert,update,delete
in the trigger?

just like get the result in the trigger:

username: Lee (i hown how to get the user's name)
SQLSTRING:' update table1 set field1='abc' where id=2 '

Page47
Master Smack Fu Yak Hacker

2878 Posts

Posted - 2002-12-23 : 08:35:22
The only thing you know is the contents of the INSERTED, DELETED and base tables. You can probably infer what happened from that.

Jay White
{0}
Go to Top of Page

ValterBorges
Master Smack Fu Yak Hacker

1429 Posts

Posted - 2002-12-23 : 09:30:26
What I usually have in my audit tables is a column for datetime, and another which has what type of modification was made.

Then my delete, update, and insert trigger will place the datetime in the datetime column and the appropriate type string in the typeofmodification column.

By comparing the record as it was before datetime and looking at the typeofmodification i'm able to tell what happened to that record.

If you're using sp's to do your data modifications then you can have the stored procedure write to a log table.

If you're trying to track down a problem you may want to use sql profiler to see what statements are being executed on your database.



Edited by - ValterBorges on 12/23/2002 09:32:34
Go to Top of Page

mfemenel
Professor Frink

1421 Posts

Posted - 2002-12-23 : 16:39:51
You could also use profiler and filter on your specific database.

Mike
"oh, that monkey is going to pay"
Go to Top of Page
   

- Advertisement -