Click here to monitor SSC
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


SSIS package to import daily SQL trace file to table


SSIS package to import daily SQL trace file to table

Author
Message
byatoo
byatoo
Forum Newbie
Forum Newbie (3 reputation)Forum Newbie (3 reputation)Forum Newbie (3 reputation)Forum Newbie (3 reputation)Forum Newbie (3 reputation)Forum Newbie (3 reputation)Forum Newbie (3 reputation)Forum Newbie (3 reputation)

Group: General Forum Members
Points: 3 Visits: 23
I need to create SSIS package to copy daily .trc file that is created every 2 hours in a new folder
And delete anything older then 8 days.
For example :
I have trace file located at C:\tracefile\2012-10-01-06-20\
C:\tracefile\2012-10-01-06-21
C:\tracefile\2012-10-01-06-22
C:\tracefile\2012-11-01-04-23
C:\tracefile\2012-11-01-04-24
And ctr
And every day I am generating 12 .trc file so inside this folder (2012-10-01-06-20) is my .trc file I need to Load it to SQL database and update one more table just with trace file name and date for reference .
So I need only 2 table inside this Database
TraceTable
infoTable.

Any help will appreciated in advance.
Lowell
Lowell
SSCoach
SSCoach (17K reputation)SSCoach (17K reputation)SSCoach (17K reputation)SSCoach (17K reputation)SSCoach (17K reputation)SSCoach (17K reputation)SSCoach (17K reputation)SSCoach (17K reputation)

Group: General Forum Members
Points: 17386 Visits: 39355
if you know the traceId(select * from sys.traces) , you can import it into a table, or create a view for it, all from within TSQL, so you probably do not need to use SSIS unless you are sending it to excel or something.


--SELECT * from sys.traces
declare @TraceIDToReview int
declare @path varchar(255)

SET @TraceIDToReview = 1 --this is the trace you want to review!
SELECT @path = path from sys.traces WHERE id = @TraceIDToReview
--INSERT INTO StaticTraceTable
SELECT
TE.name As EventClassDescrip,
v.subclass_name As EventSubClassDescrip,
TE.*
FROM ::fn_trace_gettable(@path, default) T
LEFT OUTER JOIN sys.trace_events TE ON T.EventClass = TE.trace_event_id
LEFT OUTER JOIN sys.trace_subclass_values V
ON T.EventClass = V.trace_event_id AND T.EventSubClass = V.subclass_value



or create aview and query it at will:

CREATE VIEW MySpecialTrace
AS
SELECT
TE.name As EventClassDescrip,
v.subclass_name As EventSubClassDescrip,
TE.*
FROM ::fn_trace_gettable'C:\tracefile\2012-10-01-06-20\TheTracefileName.trc', default) T
LEFT OUTER JOIN sys.trace_events TE ON T.EventClass = TE.trace_event_id
LEFT OUTER JOIN sys.trace_subclass_values V
ON T.EventClass = V.trace_event_id AND T.EventSubClass = V.subclass_value



byatoo (10/17/2012)
I need to create SSIS package to copy daily .trc file that is created every 2 hours in a new folder
For example
C:\tracefile\2012-10-01-06-20\ and in side this (2012-10-01-06-20) folder is my .trc file
Load it to SQL database lets call it DailyTrace and I have 2 table inside one for .trc (importTrace)and one (Traceinfo) to just update trace file names and time so I do not upload the same trace file again.
I use different script but some how it did not work for me.
Any help will appreciated in advance.


Lowell

--
help us help you! If you post a question, make sure you include a CREATE TABLE... statement and INSERT INTO... statement into that table to give the volunteers here representative data. with your description of the problem, we can provide a tested, verifiable solution to your question! asking the question the right way gets you a tested answer the fastest way possible!

byatoo
byatoo
Forum Newbie
Forum Newbie (3 reputation)Forum Newbie (3 reputation)Forum Newbie (3 reputation)Forum Newbie (3 reputation)Forum Newbie (3 reputation)Forum Newbie (3 reputation)Forum Newbie (3 reputation)Forum Newbie (3 reputation)

Group: General Forum Members
Points: 3 Visits: 23
Thanks Lowell,

I need to automate this process so by running sql job every 2 hours it should grab old trace file that is 2 hours behind and dump it to table and update the other table and delete old data from table.

Thanks,
byatoo
byatoo
Forum Newbie
Forum Newbie (3 reputation)Forum Newbie (3 reputation)Forum Newbie (3 reputation)Forum Newbie (3 reputation)Forum Newbie (3 reputation)Forum Newbie (3 reputation)Forum Newbie (3 reputation)Forum Newbie (3 reputation)

Group: General Forum Members
Points: 3 Visits: 23
anyone created such SSIS package or Tsql script?
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