﻿<?xml version='1.0' encoding='UTF-8'?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/"><channel><title>SQLServerCentral / SQL Server 2005 / SQL Server 2005 Performance Tuning  / Loading All Trace files / Latest Posts</title><generator>InstantForum.NET v2.9.0</generator><description>SQLServerCentral</description><link>http://www.sqlservercentral.com/Forums/</link><webMaster>notifications@sqlservercentral.com</webMaster><lastBuildDate>Fri, 24 May 2013 21:43:37 GMT</lastBuildDate><ttl>20</ttl><item><title>RE: Loading All Trace files</title><link>http://www.sqlservercentral.com/Forums/Topic1415841-360-1.aspx</link><description>Two very good idea's. Since I have very limited powershell skills, I think the second is what I will do.Thanks</description><pubDate>Wed, 06 Feb 2013 07:49:54 GMT</pubDate><dc:creator>dwilliscp</dc:creator></item><item><title>RE: Loading All Trace files</title><link>http://www.sqlservercentral.com/Forums/Topic1415841-360-1.aspx</link><description>Another option is to have the job that starts the trace add an entry into a control table after the trace is started so you can later use that to bring the trace files in.</description><pubDate>Tue, 05 Feb 2013 14:52:00 GMT</pubDate><dc:creator>opc.three</dc:creator></item><item><title>RE: Loading All Trace files</title><link>http://www.sqlservercentral.com/Forums/Topic1415841-360-1.aspx</link><description>In that case if you want to do everything in T-SQL then you will need to gain directory access. Some options are xp_cmdshell or a CLR object, there are others. I would go a different route though. Create a simple PowerShell script to iterate over any directory you need and call Invoke-Sqlcmd once for each file encountered to load the trace file into a table. When the file is loaded you can do any number of things including deleting the trace file or moving it to an archive directory, your option are wide open at that point.</description><pubDate>Tue, 05 Feb 2013 14:50:57 GMT</pubDate><dc:creator>opc.three</dc:creator></item><item><title>RE: Loading All Trace files</title><link>http://www.sqlservercentral.com/Forums/Topic1415841-360-1.aspx</link><description>Thanks, I just noticed that I left one key fact out. The trace runs for a set amount of time then stops, and SQL server removes it from sys.traces. So I have a job that re-creates the trace, at various times through out the day, when our performance is known to suffer. So the script you posted will not work, since once the hour is up.. sql server stops AND deletes the trace from sys.traces.</description><pubDate>Tue, 05 Feb 2013 14:29:20 GMT</pubDate><dc:creator>dwilliscp</dc:creator></item><item><title>RE: Loading All Trace files</title><link>http://www.sqlservercentral.com/Forums/Topic1415841-360-1.aspx</link><description>Borrowed from [u][url=http://sqlblog.com/blogs/aaron_bertrand/archive/2007/01/11/reviewing-autogrow-events-from-the-default-trace.aspx]here[/url][/u] and tweaked slightly:[code="sql"]DECLARE @trace_id INT = 1,    @path NVARCHAR(260);SELECT  @path = REVERSE(SUBSTRING(REVERSE([path]), CHARINDEX('\', REVERSE([path])), 260)) + N'log.trc'FROM    sys.traces-- set this id each time up above or come up with another identifier you can count on to get a specific trace id from sys.traces, e.g. path like '%something%'WHERE   id = @trace_id;SELECT  DatabaseName,        [FileName],        SPID,        Duration,        StartTime,        EndTime,        FileType = CASE EventClass                     WHEN 92 THEN 'Data'                     WHEN 93 THEN 'Log'                   ENDFROM    sys.fn_trace_gettable(@path, DEFAULT)WHERE   EventClass IN ( 92, 93 )ORDER BY StartTime DESC;[/code]</description><pubDate>Tue, 05 Feb 2013 10:54:51 GMT</pubDate><dc:creator>opc.three</dc:creator></item><item><title>Loading All Trace files</title><link>http://www.sqlservercentral.com/Forums/Topic1415841-360-1.aspx</link><description>I was wondering if someone had already put the SQL together to load all trace files in a folder, into a SQL table. I have the following code.. that I modify for each trace file created during the previous day. insert into zt_trace_dataSELECT     cast(TextData as varchar(4000)) as TextData, BinaryData, DatabaseID, TransactionID, LineNumber, NTUserName, NTDomainName, HostName, ClientProcessID, ApplicationName,                       LoginName, SPID, Duration, StartTime, EndTime, Reads, Writes, CPU, Permissions, Severity, EventSubClass, ObjectID, Success, IndexID, IntegerData,                       ServerName, EventClass, ObjectType, NestLevel, State, Error, Mode, Handle, ObjectName, DatabaseName, FileName, OwnerName, RoleName,                       TargetUserName, DBUserName, LoginSid, TargetLoginName, TargetLoginSid, ColumnPermissions, LinkedServerName, ProviderName, MethodName,                       RowCounts, RequestID, XactSequence, EventSequence, BigintData1, BigintData2, GUID, IntegerData2, ObjectID2, Type, OwnerID, ParentName,                       IsSystem, Offset, SourceDatabaseID, SqlHandle, SessionLoginName, PlanHandleFROM fn_trace_gettable(N'C:\TraceFiles\SQL_Performance_20130201040000.trc',DEFAULT);</description><pubDate>Tue, 05 Feb 2013 07:40:17 GMT</pubDate><dc:creator>dwilliscp</dc:creator></item></channel></rss>