469,081 Members | 1,753 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,081 developers. It's quick & easy.

tracing sql from code

Hi
I want to trace all the selects/deletes/modifys whatever on a database
in an application that are performed in a seperate application.
I need to look into this, any ideas?

- Can triggers do this kind of thing
- Can you somehow access the profiler via OLE or similiar to do this?
- Anything else?

Ta
F
Jul 20 '05 #1
5 1508
(fo******@yahoo.co.uk) writes:
I want to trace all the selects/deletes/modifys whatever on a database
in an application that are performed in a seperate application.
I need to look into this, any ideas?

- Can triggers do this kind of thing
- Can you somehow access the profiler via OLE or similiar to do this?
- Anything else?


It would probably help if you told us what you want to achieve with this.
If you are into auditing, check out Entegra from Lumgient
(www.lumigent.com.)

If you want to write your Profiler-sort-of-thing, you can use server-side
traces. Look up the sp_trace_xxxx procedures in Books Online.
--
Erland Sommarskog, SQL Server MVP, so****@algonet.se

Books Online for SQL Server SP3 at
http://www.microsoft.com/sql/techinf...2000/books.asp
Jul 20 '05 #2
Erland Sommarskog <so****@algonet.se> wrote in message news:<Xn**********************@127.0.0.1>...
(fo******@yahoo.co.uk) writes:
I want to trace all the selects/deletes/modifys whatever on a database
in an application that are performed in a seperate application.
I need to look into this, any ideas?

- Can triggers do this kind of thing
- Can you somehow access the profiler via OLE or similiar to do this?
- Anything else?


It would probably help if you told us what you want to achieve with this.
If you are into auditing, check out Entegra from Lumgient
(www.lumigent.com.)

If you want to write your Profiler-sort-of-thing, you can use server-side
traces. Look up the sp_trace_xxxx procedures in Books Online.


Its my my own debugging use. I've got a little utility that shows a list
of tables and the records of that table in a DataGrid on the right. I would
like to be able to press a button on that tool, do some database stuff,
then press some other button and see all the tables that have been modified
turn red.
Again, this is just for my own debugging use and I can completely reck the
database if need-be so anything goes.

Thanks for the response, the sp_trace_xxx stuff sounds like what I need. As
I'm new to (relational) databases it would be nice to know what else is
out there that can do this kind of thing. Can you make the database call
a program via some kind of Observer pattern, something else?
I only just learnt about the sysobjects table the other day and thats proved
to be dead useful.
Jul 20 '05 #3
(fo******@yahoo.co.uk) writes:
Thanks for the response, the sp_trace_xxx stuff sounds like what I
need. As I'm new to (relational) databases it would be nice to know what
else is out there that can do this kind of thing. Can you make the
database call a program via some kind of Observer pattern, something
else?


You can call external code in two ways: OLE objects or extended stored
procedures (XP). Writing your own XPs is certainly an advanced feature,
and requires C/C++ skills. Once they are there, calling them is more
or less like calling any other SP. To talk with OLE objects you use
the system procedures on the family sp_OAxxxx.

But I cannot see than any of these has any place in what you want to do
for debugging.

--
Erland Sommarskog, SQL Server MVP, so****@algonet.se

Books Online for SQL Server SP3 at
http://www.microsoft.com/sql/techinf...2000/books.asp
Jul 20 '05 #4
> You can call external code in two ways: OLE objects or extended stored
procedures (XP). Writing your own XPs is certainly an advanced feature,
and requires C/C++ skills.
c#? Doing mainly web stuff at the mo but can do Windows Forms stuff as well
Once they are there, calling them is more
or less like calling any other SP. To talk with OLE objects you use
the system procedures on the family sp_OAxxxx.

But I cannot see than any of these has any place in what you want to do
for debugging.


just thinking from an mvc type of view, table changes, view is informed.
Probably not the way to go though.
Jul 20 '05 #5
(fo******@yahoo.co.uk) writes:
You can call external code in two ways: OLE objects or extended stored
procedures (XP). Writing your own XPs is certainly an advanced feature,
and requires C/C++ skills.


c#? Doing mainly web stuff at the mo but can do Windows Forms stuff as
well


Don't know if you can write unmanaged code in C#, but if you can maybe.
But you are certainly not in the sheltered realms of the CLR, but you
are responsible for keeping track of your pointers yourself. And this is
even more nervous in the context of an extended stored procedure. Tt's
not only your small little DLL that perishes in case of an access
violation - you will bring the entire SQL Server with you in the fall.

--
Erland Sommarskog, SQL Server MVP, so****@algonet.se

Books Online for SQL Server SP3 at
http://www.microsoft.com/sql/techinf...2000/books.asp
Jul 20 '05 #6

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

reply views Thread by Paul Ibison | last post: by
5 posts views Thread by Dabbler | last post: by
6 posts views Thread by serge calderara | last post: by
2 posts views Thread by deepukutty | last post: by
3 posts views Thread by Tim Mavers | last post: by
reply views Thread by cnys | last post: by
reply views Thread by rehto | last post: by
6 posts views Thread by Stephen Torri | last post: by
1 post views Thread by RedLars | last post: by
1 post views Thread by CARIGAR | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.