Fuzz Evans
Fuzz Evans

Reputation: 2943

How to programatically update SQL Server Profiler template

I work with a variety of databases for work on any given day. I have built a C# tool that changes which database my system is connecting to for testing.

When I change the connection details for my database, I would like to also update this value in my SQL Server Profiler template (not trace file - the actual template).

I found this question from 12 years ago with no answer: SQL Profiler Template File Format

I'm curious if there might be any new insight in the past decade that could be useful here?

The file is a *.tdf file, and the contents are not readable in plain text.

However, my database name as defined in the template properties is in plain text.

I have looked at reading the file contents as strings, but it considers those NULL values string terminators which means I haven't been able to access the database value between them.

I have also played with ReadAllBytes and then trying to extract the bytes that way - but haven't been successful - though this seems the most probable approach so far.

Does anyone have any ideas on how to modify the *.tdf file programmatically so I can simply set my database name directly into the file?

It's worth noting, that if I open the file in notepad++, modify the database name there, and save, the Profiler GUI will reflect the changes correctly - so I believe doing it programmatically should work provided I can come up with a way how.

enter image description here

Upvotes: 0

Views: 101

Answers (0)

Related Questions