[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

SQL Trace or SQL Trigger

Posted on 2010-01-06
5
Medium Priority
?
656 Views
Last Modified: 2012-08-14
Hi to all,

I am trying to trace insert, delete or updates on 4 tables in my SQL database. I am not very good with SQL pro-filer and I don't know how to create a trace on only 4 tables. The trace I currently have shows ALL SQL queries on the whole database and the is to much. I read that a trigger might be a better way to go, but I also do not know how to create a trigger to accomplish that.

The tables I want to trace is: PurchaseOrder and PurchaseOrderDetails. Workorder and WorkorderDetails.

What is the best way to go and is there a sample or walk through that I can use or work with.

Thanks to all
0
Comment
Question by:ALawrence007
5 Comments
 
LVL 26

Expert Comment

by:tigin44
ID: 26195675
what do you want to audit about these tables?
0
 
LVL 15

Accepted Solution

by:
Faiga Diegel earned 1000 total points
ID: 26195743
0
 

Author Comment

by:ALawrence007
ID: 26199076
I am trying to see what the insert, update and delete statement looked like as well as the values was inserted, updated and deleted.
0
 
LVL 3

Assisted Solution

by:SQLTriVegg
SQLTriVegg earned 1000 total points
ID: 26280168
You can still use the results of your Trace to examine your insert, update, etc. statements.  

Are the results of your trace in a file, or in a table?  In the trace, there is probably a column called TextData.  Add the below like to your WHERE clause and you should have a comprehensive list of all statementents on that table, as well as the values.

WHERE TextData Like '%MyTableName%'

If your trace has been saved to a file(s), you can query it using this system function:
SELECT *
FROM ::fn_trace_gettable('FullPathAndFileName.trc', default)

0
 

Author Closing Comment

by:ALawrence007
ID: 31673780
It took me a while, but I got there in the end.
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I have a large data set and a SSIS package. How can I load this file in multi threading?
In the first part of this tutorial we will cover the prerequisites for installing SQL Server vNext on Linux.
Familiarize people with the process of retrieving data from SQL Server using an Access pass-thru query. Microsoft Access is a very powerful client/server development tool. One of the ways that you can retrieve data from a SQL Server is by using a pa…
Using examples as well as descriptions, and references to Books Online, show the documentation available for date manipulation functions and by using a select few of these functions, show how date based data can be manipulated with these functions.
Suggested Courses

830 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question