0

I'm trying to replay SQL Server 2014 Profiler trace that I saved to a DB table. When I open I get "Failed to open a table" error message. There is nothing in the windows logs.

I googled and this error used to happen when upgrading a SQL Server 2000 system to a 64 bit system. That doesn't apply here. I'm running on Windows Server 2012 with a fresh install of SQL Server 2014.

The trace was a TSQL_replay template. I saved it to a table using the following code. The code produced a table with the definition shown.

SELECT * 
INTO myTrace 
FROM ::fn_trace_gettable(N'c:\Logs\sql_trace_events.trc', default)

CREATE TABLE [dbo].[myTrace]
(
    [TextData] [ntext] NULL,
    [BinaryData] [image] NULL,
    [DatabaseID] [int] NULL,
    [TransactionID] [bigint] NULL,
    [LineNumber] [int] NULL,
    [NTUserName] [nvarchar](256) NULL,
    [NTDomainName] [nvarchar](256) NULL,
    [HostName] [nvarchar](256) NULL,
    [ClientProcessID] [int] NULL,
    [ApplicationName] [nvarchar](256) NULL,
    [LoginName] [nvarchar](256) NULL,
    [SPID] [int] NULL,
    [Duration] [bigint] NULL,
    [StartTime] [datetime] NULL,
    [EndTime] [datetime] NULL,
    [Reads] [bigint] NULL,
    [Writes] [bigint] NULL,
    [CPU] [int] NULL,
    [Permissions] [bigint] NULL,
    [Severity] [int] NULL,
    [EventSubClass] [int] NULL,
    [ObjectID] [int] NULL,
    [Success] [int] NULL,
    [IndexID] [int] NULL,
    [IntegerData] [int] NULL,
    [ServerName] [nvarchar](256) NULL,
    [EventClass] [int] NULL,
    [ObjectType] [int] NULL,
    [NestLevel] [int] NULL,
    [State] [int] NULL,
    [Error] [int] NULL,
    [Mode] [int] NULL,
    [Handle] [int] NULL,
    [ObjectName] [nvarchar](256) NULL,
    [DatabaseName] [nvarchar](256) NULL,
    [FileName] [nvarchar](256) NULL,
    [OwnerName] [nvarchar](256) NULL,
    [RoleName] [nvarchar](256) NULL,
    [TargetUserName] [nvarchar](256) NULL,
[DBUserName] [nvarchar](256) NULL,
[LoginSid] [image] NULL,
[TargetLoginName] [nvarchar](256) NULL,
[TargetLoginSid] [image] NULL,
[ColumnPermissions] [int] NULL,
[LinkedServerName] [nvarchar](256) NULL,
[ProviderName] [nvarchar](256) NULL,
[MethodName] [nvarchar](256) NULL,
[RowCounts] [bigint] NULL,
[RequestID] [int] NULL,
[XactSequence] [bigint] NULL,
[EventSequence] [bigint] NULL,
[BigintData1] [bigint] NULL,
[BigintData2] [bigint] NULL,
[GUID] [uniqueidentifier] NULL,
[IntegerData2] [int] NULL,
[ObjectID2] [bigint] NULL,
[Type] [int] NULL,
[OwnerID] [int] NULL,
[ParentName] [nvarchar](256) NULL,
[IsSystem] [int] NULL,
[Offset] [int] NULL,
[SourceDatabaseID] [int] NULL,
[SqlHandle] [image] NULL,
[SessionLoginName] [nvarchar](256) NULL,
[PlanHandle] [image] NULL,
[GroupID] [int] NULL
) 
marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
Tom McDonald
  • 1,532
  • 2
  • 18
  • 37

4 Answers4

0

I tried the same thing and I did not run into any issues. Have you tried with a new trace and save to a different named table?

SELLTSLA
  • 1
  • 4
0

You have to wait...the 'replay' is grayed out for about 1 minute until it fully loads the script.

Tom McDonald
  • 1,532
  • 2
  • 18
  • 37
0

Had the same issue and it turned out I was trying to open a trace recorded in Profiler 2014 with Profiler 2008 on a diffrent SQL instance in order to reply the trace. Upgrading profiler to 2014 on a replay instance solved the problem.

0

You have to create table of specific structure first. Try to export trace into a table from profiler and look what it created. Then just insert subset of columns into the table. Here is what I used for SQL 2012-2017:

------- Trace created with Replay template

USE [testdb]

GO 

/****** Object:  Table [dbo].[TraceTable]    Script Date: 29-Oct-18 17:37:07 ******/ 
SET ANSI_NULLS ON 
GO 

SET QUOTED_IDENTIFIER ON

GO 

CREATE TABLE [dbo].[TraceTableSQL1] 
( 
    [RowNumber] [int] IDENTITY ( 0 , 1 ) NOT NULL , 
    [EventClass] [int] NULL , 
    [BinaryData] [image] NULL , 
    [DatabaseID] [int] NULL , 
    [NTUserName] [nvarchar] ( 128 ) NULL , 
    [NTDomainName] [nvarchar] ( 128 ) NULL , 
    [HostName] [nvarchar] ( 128 ) NULL , 
    [ClientProcessID] [int] NULL , 
    [ApplicationName] [nvarchar] ( 128 ) NULL , 
    [LoginName] [nvarchar] ( 128 ) NULL , 
    [SPID] [int] NULL , 
    [StartTime] [datetime] NULL , 
    [EndTime] [datetime] NULL , 
    [Error] [int] NULL , 
    [DatabaseName] [nvarchar] ( 128 ) NULL , 
    [RowCounts] [bigint] NULL , 
    [RequestID] [int] NULL , 
    [EventSequence] [bigint] NULL , 
    [IsSystem] [int] NULL , 
    [ServerName] [nvarchar] ( 128 ) NULL , 
    [TextData] [ntext] NULL , 
    [EventSubClass] [int] NULL , 
    [Handle] [int] NULL , 
    PRIMARY KEY CLUSTERED 
    ( 
        [RowNumber] ASC 
    ) 
    WITH ( PAD_INDEX = OFF , STATISTICS_NORECOMPUTE = OFF , IGNORE_DUP_KEY = OFF , ALLOW_ROW_LOCKS = ON , ALLOW_PAGE_LOCKS = ON ) ON [PRIMARY] 
) 
ON [PRIMARY] TEXTIMAGE_ON [PRIMARY] 
GO 

INSERT [TraceTableSQL1] 
SELECT 
[EventClass] , 
[BinaryData] , 
[DatabaseID] , 
[NTUserName] , 
[NTDomainName] , 
[HostName] , 
[ClientProcessID] , 
[ApplicationName] , 
[LoginName] , 
[SPID] , 
[StartTime] , 
[EndTime] , 
[Error] , 
[DatabaseName] , 
[RowCounts] , 
[RequestID] , 
[EventSequence] , 
[IsSystem] , 
[ServerName] , 
[TextData] , 
[EventSubClass] , 
[Handle] 
FROM sys.fn_trace_gettable ( N'd:\temp\profiler.trc' , DEFAULT )
Dmitry V A
  • 16
  • 1