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
 General SQL Server Forums
 New to SQL Server Programming
 SQL tracking

Author  Topic 

yalgaar
Starting Member

43 Posts

Posted - 2006-03-06 : 14:42:22
I have an application that uses SQL server. Is there a way to find out what SQL statements the application is passing to the SQL server?

I would like to know all kinds of activities going on in the background of the application. I am sure there is a way.

Thanks in advance.

JoeNak
Constraint Violating Yak Guru

292 Posts

Posted - 2006-03-06 : 14:45:55
You can run a trace with Profiler.
Go to Top of Page

yalgaar
Starting Member

43 Posts

Posted - 2006-03-06 : 14:48:51
Can you please provide more details on that?


Thanks
Go to Top of Page

JoeNak
Constraint Violating Yak Guru

292 Posts

Posted - 2006-03-06 : 15:05:47
Basically, a trace lets you see activity on a server.

Check out BOL (SQL Profiler or trace)
http://vyaskn.tripod.com/analyzing_profiler_output.htm
Go to Top of Page

yalgaar
Starting Member

43 Posts

Posted - 2006-03-06 : 15:06:38
Since I do not got the response that I am looking for, I will be more specific:

Is there any SQL logs that matains everything that was done on the server on each table, each database? I need information of all SQL statements that were ran on the SQL server?

Is this available in any files or do I have to turn ON something?
Go to Top of Page

JoeNak
Constraint Violating Yak Guru

292 Posts

Posted - 2006-03-06 : 15:12:28
You have to have a trace running and you will only be able to see activity from when you start the trace. The only other thing I can come up with is to look through the transaction logs, but you need a third party application to read the transaction logs.
Go to Top of Page

yalgaar
Starting Member

43 Posts

Posted - 2006-03-06 : 15:44:26
I followed the instructions in the link. It seems I may not be doing something correctly, but currently I am getting a huge amount of data in the trace table. Is there a way that I can get only the SQL statements?
Go to Top of Page

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2006-03-06 : 15:48:07
I typically only add Stored Procedures: SP:StmtCompleted and T-SQL: SQL:StmtCompleted. That should narrow it down for you.

Tara Kizer
aka tduggan
Go to Top of Page

JoeNak
Constraint Violating Yak Guru

292 Posts

Posted - 2006-03-06 : 16:01:32
nevermind.
Go to Top of Page

yalgaar
Starting Member

43 Posts

Posted - 2006-03-06 : 16:09:11
quote:
Originally posted by tkizer

I typically only add Stored Procedures: SP:StmtCompleted and T-SQL: SQL:StmtCompleted. That should narrow it down for you.

Tara Kizer
aka tduggan



My application requests several queries. I just want to see Select statements. Can this be done?
Go to Top of Page

JoeNak
Constraint Violating Yak Guru

292 Posts

Posted - 2006-03-06 : 16:19:22
Yes, profiler lets you filter on a variety of criteria. The statement can be filtered by TextData. You could also filter by application, login...
Go to Top of Page

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2006-03-06 : 16:39:42
I prefer not to filter unless it is by loginame or hostname.

Trace the data to a SQL Server Table. Then you can use T-SQL to view what you want to see. Such as:

SELECT TextData
FROM YourTraceTableName
WHERE TextData LIKE '%SELECT%'


Tara Kizer
aka tduggan
Go to Top of Page
   

- Advertisement -