SQL Clone
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


Server side trace to a table


Server side trace to a table

Author
Message
sunny.tjk
sunny.tjk
SSC-Addicted
SSC-Addicted (479 reputation)SSC-Addicted (479 reputation)SSC-Addicted (479 reputation)SSC-Addicted (479 reputation)SSC-Addicted (479 reputation)SSC-Addicted (479 reputation)SSC-Addicted (479 reputation)SSC-Addicted (479 reputation)

Group: General Forum Members
Points: 479 Visits: 1344
The link below helps me to create a server side trace to a file. I'd like to send the results to a table. Could some please tell me what change I need to make in the script to send the results out to a table?
http://sqlserverpedia.com/wiki/The_Server-side_Trace:_What,_Why,_and_How

And also, I was told that server side tracing to a table in SQL 2000/2005 is different from SQL 2008. Is it?
Jack Corbett
  Jack Corbett
SSCoach
SSCoach (18K reputation)SSCoach (18K reputation)SSCoach (18K reputation)SSCoach (18K reputation)SSCoach (18K reputation)SSCoach (18K reputation)SSCoach (18K reputation)SSCoach (18K reputation)

Group: General Forum Members
Points: 18286 Visits: 14889
You can't write directly to a table with a server-side trace. Even if you could it wouldn't be wise as it would not perform as well as writing to a file and would have a negative impact on overall server performance.

You get read the trace file using fn_trace_gettable([path to file]) and use that to load the trace data into a table if you want to do that.



Jack Corbett

Applications Developer

Don't let the good be the enemy of the best. -- Paul Fleming
At best you can say that one job may be more secure than another, but total job security is an illusion. -- Rod at work

Check out these links on how to get faster and more accurate answers:
Forum Etiquette: How to post data/code on a forum to get the best help
Need an Answer? Actually, No ... You Need a Question
How to Post Performance Problems
Crosstabs and Pivots or How to turn rows into columns Part 1
Crosstabs and Pivots or How to turn rows into columns Part 2
Perry Whittle
Perry Whittle
SSCoach
SSCoach (19K reputation)SSCoach (19K reputation)SSCoach (19K reputation)SSCoach (19K reputation)SSCoach (19K reputation)SSCoach (19K reputation)SSCoach (19K reputation)SSCoach (19K reputation)

Group: General Forum Members
Points: 19692 Visits: 17239
Using fn_trace_gettable you'll need to supply the file and path and the number of files to read. As below

Load 10 files

select * into my_trace 
from fn_trace_gettable('c:\mypath\mytrace.trc', 10)




Load all files

select * into my_trace 
from fn_trace_gettable('c:\mypath\mytrace.trc', default)



-----------------------------------------------------------------------------------------------------------

"Ya can't make an omelette without breaking just a few eggs" ;-)
raghu_kalwa
raghu_kalwa
Forum Newbie
Forum Newbie (7 reputation)Forum Newbie (7 reputation)Forum Newbie (7 reputation)Forum Newbie (7 reputation)Forum Newbie (7 reputation)Forum Newbie (7 reputation)Forum Newbie (7 reputation)Forum Newbie (7 reputation)

Group: General Forum Members
Points: 7 Visits: 2
Hello Perry,

I have used the SQL server profiler,.

So can you suggest me which one is best solution to take the trace on the server .

The SQL server profiler or Server side trace ??

Thanks
Rag
Jack Corbett
  Jack Corbett
SSCoach
SSCoach (18K reputation)SSCoach (18K reputation)SSCoach (18K reputation)SSCoach (18K reputation)SSCoach (18K reputation)SSCoach (18K reputation)SSCoach (18K reputation)SSCoach (18K reputation)

Group: General Forum Members
Points: 18286 Visits: 14889
raghu_kalwa (8/7/2013)
Hello Perry,

I have used the SQL server profiler,.

So can you suggest me which one is best solution to take the trace on the server .

The SQL server profiler or Server side trace ??

Thanks
Rag


A server-side trace has a much lower performance impact than using profiler, see this blog post by Linchi Shea, http://sqlblog.com/blogs/linchi_shea/archive/2007/08/01/trace-profiler-test.aspx and this one by Jonathan Kehayais, http://www.sqlperformance.com/2012/10/sql-trace/observer-overhead-trace-extended-events



Jack Corbett

Applications Developer

Don't let the good be the enemy of the best. -- Paul Fleming
At best you can say that one job may be more secure than another, but total job security is an illusion. -- Rod at work

Check out these links on how to get faster and more accurate answers:
Forum Etiquette: How to post data/code on a forum to get the best help
Need an Answer? Actually, No ... You Need a Question
How to Post Performance Problems
Crosstabs and Pivots or How to turn rows into columns Part 1
Crosstabs and Pivots or How to turn rows into columns Part 2
Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum

































































































































































SQLServerCentral


Search