Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase ««123»»

Using SQL Trace to Audit Database Access Expand / Collapse
Author
Message
Posted Tuesday, September 23, 2003 10:50 AM
Mr or Mrs. 500

Mr or Mrs. 500Mr or Mrs. 500Mr or Mrs. 500Mr or Mrs. 500Mr or Mrs. 500Mr or Mrs. 500Mr or Mrs. 500Mr or Mrs. 500

Group: General Forum Members
Last Login: Friday, May 2, 2014 6:14 PM
Points: 564, Visits: 347
Haidong, thank you for your reply.

I used the extended stored procedure created a couple of trace running on SQL 7, we are in the process of upgrading to SQL 2000.

In SQL 7, there is an extended stored procedure: xp_trace_setqueueautostart
which will make the trace automatically started whenever the server is reboot. But i didn't find the same thing in SQL 2000, that's why i asking the question.

I thought the way you mentioned before, it will restart the trace whenever the Agent is restart, but what happen if you only restart the Agent without restarting the SQL Server ?

Again, thank you for your help.





Post #49449
Posted Tuesday, September 23, 2003 4:04 PM
Valued Member

Valued MemberValued MemberValued MemberValued MemberValued MemberValued MemberValued MemberValued Member

Group: General Forum Members
Last Login: Friday, January 18, 2013 11:03 AM
Points: 55, Visits: 60
awu,

Tracing and profling have been totally redesigned for SQL 2k, that's why you couldn't see xp_trace_setqueueautostart and other extended stored procedures for tracing.

When you start SQL Agent, SQL Server Service will be started automatically, as SQL Agent service is dependent on SQL Server service.

Hope this helps.

Haidong



Post #49450
Posted Wednesday, September 24, 2003 12:14 PM
Mr or Mrs. 500

Mr or Mrs. 500Mr or Mrs. 500Mr or Mrs. 500Mr or Mrs. 500Mr or Mrs. 500Mr or Mrs. 500Mr or Mrs. 500Mr or Mrs. 500

Group: General Forum Members
Last Login: Friday, May 2, 2014 6:14 PM
Points: 564, Visits: 347
No, Haidong, I don't agree with you on "When you start SQL Agent, SQL Server Service will be started automatically, as SQL Agent service is dependent on SQL Server service."

For my understanding, it’s true that when you restart SQL Server, the SQL Agent will restarted automatically, but you are able to restart Agent without restart SQL Server, so my question is, If we put a job to run the your script automatically when the Agent is start, then do we need to check if the existing trace still active, and remove it first before we create another one ? I am afraid we may create multi trace in the system.

Again, thank you for your time.





Post #49451
Posted Wednesday, September 24, 2003 3:40 PM
Valued Member

Valued MemberValued MemberValued MemberValued MemberValued MemberValued MemberValued MemberValued Member

Group: General Forum Members
Last Login: Friday, January 18, 2013 11:03 AM
Points: 55, Visits: 60
awu,

I suggest you DO the following:
1. Stop both SQL Server Service and SQL Server Agent service;
2. Start SQL Server Agent service. Then verify to see if SQL Server service starts automatically;
3. Again, stop both SQL Server Service and SQL Server Agent service. Now start SQL Server Service. Check SQL Agent service and see if it is started.

After you've done the above, assuming you are running Win2K or above and go to Computer Management. Then go to Services. Make sure SQL Agent service's startup type is Automatic. For WinNT, go to Control Panel, then Services.

Yes, you are able to stop and restart SQL Agent without affecting SQL Server service. I don't have time to test that scenario, but I would agree that the existing trace would still be active, if it is not timed out or stopped manually.





Post #49452
Posted Thursday, September 25, 2003 4:28 PM
Mr or Mrs. 500

Mr or Mrs. 500Mr or Mrs. 500Mr or Mrs. 500Mr or Mrs. 500Mr or Mrs. 500Mr or Mrs. 500Mr or Mrs. 500Mr or Mrs. 500

Group: General Forum Members
Last Login: Friday, May 2, 2014 6:14 PM
Points: 564, Visits: 347
Haidong,

You are right in your sense, I think we are just not in the same page for the same question, my original concern is :

if you put the sp in a job and configure it as "Start automatically when SQL Server Agent starts", then what happen if you only restart the Agent without restarting the SQL Server ? I am afraid we may create multiple trace in the system.

And you actually give me the answer by saying:

Yes, you are able to stop and restart SQL Agent without affecting SQL Server service. I don't have time to test that scenario, but I would agree that the existing trace would still be active, if it is not timed out or stopped manually.

And i test it today, it did keeping create new active trace in the system each time you stop and start Agent service, i fixed this simply put the following the first line inside the SP:

IF EXISTS (select * from ::fn_trace_getinfo(0) where property=5 and value=1) Return

But be aware of the fact, this assume you have only one active trace on the server, and it's true in my system.

Just wanna share this with you, again, thank you for your help, it's great script.




Post #49453
Posted Thursday, September 25, 2003 6:00 PM
Valued Member

Valued MemberValued MemberValued MemberValued MemberValued MemberValued MemberValued MemberValued Member

Group: General Forum Members
Last Login: Friday, January 18, 2013 11:03 AM
Points: 55, Visits: 60
awu,

I am happy it worked out for you. Glad to be of help.

Haidong




Post #49454
Posted Monday, January 19, 2004 12:54 AM
SSC Rookie

SSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC Rookie

Group: General Forum Members
Last Login: Tuesday, September 9, 2008 2:52 PM
Points: 43, Visits: 3

Hi,

What you say about this trace select into your analyze table - i used

SELECT * INTO dbo.Analyze FROM :: fn_trace_gettable('\\MYHOST\SHAREDFOLDER\trace_filename.trc', default)

and after giving anyone all access to this folder that works well...

 

Post #95939
Posted Wednesday, May 31, 2006 4:52 AM
Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum Newbie

Group: General Forum Members
Last Login: Friday, June 9, 2006 5:00 AM
Points: 4, Visits: 1
 

Hello,

I have one  question. The article was very good, I made changes to the script so I could trace what I needed to. One more thing, I am trying to filter not just by application name (column 10) but also by the name of the application so I will get activity for that particular app and I am not having much luck. I am poblably missing something simple but...could you help please?

Thanks a lot

Monica

Post #283822
Posted Thursday, May 1, 2008 12:05 PM
Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum Newbie

Group: General Forum Members
Last Login: Tuesday, February 17, 2009 5:50 AM
Points: 1, Visits: 12
When I stop running trace, I still cannot open trace file. It seems to keep a lock to it.
Post #493822
Posted Tuesday, September 9, 2008 2:49 PM
Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum Newbie

Group: General Forum Members
Last Login: Friday, September 17, 2010 6:13 AM
Points: 1, Visits: 87
Too cool.

Thanks.
Post #566489
« Prev Topic | Next Topic »

Add to briefcase ««123»»

Permissions Expand / Collapse