How can I change the target server type for a trace template?

If you open Profiler, go to File > Templates > Import and choose your .tdf file.

You will have a new user trace template with the name [filename] (without the .tdf). Go to File > Templates > Edit and pick the trace template you imported. You should then be able to edit the server type by pulling the dropdown:

enter image description here

Then you can save the template and that should be the server type when you start a new trace using that template.


I'm using Profiler 2012, talking to 2008, 2008 R2, and 2012 databases. I had to use a slightly different workflow than in the accepted answer.

When I try to follow that workflow, to migrate a template from 2008 to 2012, the Select template name dropdown depopulates, and clicking Save or Save As prompts me to choose a template to save.

enter image description here

Instead, copy your template from the 2012 profiler, 2008 templates folder (should be %APPDATA%\Microsoft\SQL Profiler\11.0\Templates\Microsoft SQL Server\100) to the 2012 profiler, 2012 templates folder (should be %APPDATA%\Microsoft\SQL Profiler\11.0\Templates\Microsoft SQL Server\110)

Now, go to File > New Trace... and choose the copied template to perform a trace on a 2012 server. Verify the trace is running and capturing what you want.

At this point, you're pretty good - you can use the copied template to start traces. But if you want to make modifications on it, when you go to File > Templates > Edit Template... and choose Events Selection you get a prompt indicating the trace is in the wrong format:

enter image description here

To save it in the new format: start the trace running using File > New Trace... as mentioned above, then with the trace running do File > Save As > Trace Template... and choose a new name. You can now delete the originally copied template, and use the newly saved template in its place.


Actually there is only need change two bytes in tdf file. I created a tiny PowerShell script to do that. mssql.profiler.template.sql_ver.chg.ps1 (GitHub)

<# 
.SYNOPSIS
    Changing sql server target version in *.tdf (profiler trace template) file.
.DESCRIPTION
    Changing sql server target version in *.tdf (trace template) file.
    To create *.tdf go to <SQL Server Profiler>\"File"\"Templates"\"Export Template...". To load *.tdf into templates list go to <SQL Server Profiler>\"File"\"Templates"\"Import Template..."
.PARAMETER iPath
    Source *.tdf file.
.PARAMETER iPathNew
    Destination *.tdf file. If ommitted then file $iPath will be rewrited. If file $iPathNew exists it will be overwrited.
.PARAMETER iVerNew
    Required target MS SQL Version for trace template in format 'X.X' or 'X'.
    Eg: 10.5 for MS SQL Server 2008 R2, 11 for MS SQL Server 2012. You can google it with query "ms sql versions".
.INPUTS
    <none>
.OUTPUTS
    <none>
.EXAMPLE
    mssql.profiler.template.sql_ver.chg.ps1 try_105.tdf try_13.tdf 13
    Will create file try_13.tdf with target sql server 2016 (version 13.0).
.LINK
    https://github.com/TEH30P/MSSQL.Profiler
#>

param
(   [parameter(Mandatory=1, position=0)][String]$iPath
,   [parameter(Mandatory=0, position=1)][String]$iPathNew
,   [parameter(Mandatory=0, position=2)][String]$iVerNew
)

try {

if ([IO.Path]::GetExtension($iPath) -ne '.tdf')
{   [String]$Answ = Read-Host -Prompt 'It is not a *.tdf file. Are you sure? {Y|[N]}';

    if (!$Answ.Length -or $Answ -eq 'N')
    {   throw 'Canceled'}
}

[String]$PathAbs = (Convert-Path $iPath);
[Byte[]]$aBuff = [IO.File]::ReadAllBytes($PathAbs);

if ($aBuff.Count -le 391)
{   throw 'File is to small. Possible corrupted.'}

if ([String]::IsNullOrEmpty($iVerNew))
{   $iVerNew = Read-Host -Prompt "Current version is $($aBuff[390]).$($aBuff[391]). Enter new version:";

    if (!$iVerNew.Length)
    {   throw 'Canceled'}
}

[Version]$Ver = New-Object Version;
[UInt32]$VerMajor = 0;
[UInt32]$VerMinor = 0;

if (![UInt32]::TryParse($iVerNew, [ref]$VerMajor))
{   [Version]$iVerNew | % {$VerMajor = $_.Major; $VerMinor = "$($_.Minor)0".Substring(0,2)}}

$aBuff[390] = $VerMajor;
$aBuff[391] = $VerMinor;

if (![String]::IsNullOrEmpty($iPathNew))
{   [String]$PathAbs = (Convert-Path $iPathNew)}

[IO.File]::WriteAllBytes($PathAbs, $aBuff);

} catch 
{   throw}