# SQL Script for Storing MiniProfiler Timing in SQL Azure

**URL:** <https://community.miniprofiler.com/t/sql-script-for-storing-miniprofiler-timing-in-sql-azure/36>\
**Category:** uncategorized\
**Created:** [January 10, 2013, 3:10am UTC](https://community.miniprofiler.com/t/sql-script-for-storing-miniprofiler-timing-in-sql-azure/36 "2013-01-10T03:10:23Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Unknown36](https://avatars.discourse-cdn.com/v4/letter/u/ed8c4c/32.png) [@Unknown36](https://community.miniprofiler.com/u/Unknown36)\
**Post date:** [January 10, 2013, 3:10am UTC](https://community.miniprofiler.com/t/sql-script-for-storing-miniprofiler-timing-in-sql-azure/36/1 "2013-01-10T03:10:23Z")

</div>

Hi,

Please forgive me if this is not the right place for this but here’s a script I’ve developed today to allow me to port an on-premise application into Azure.

Nothing earth shattering other than SQL Azure does’nt support non-clustered indexes so I had to tweak the SQL a tiny bit.

```
/******Object: Table [dbo].[MiniProfilerClientTimings] Script Date: 10/01/2013 13:50:31******/

```

SET ANSI\_NULLS ON  
GO

SET QUOTED\_IDENTIFIER ON  
GO

CREATE TABLE [dbo].[MiniProfilerClientTimings](  
[MiniProfilerId] [uniqueidentifier] NOT NULL,  
[Name] nvarchar NOT NULL,  
[Start] [decimal](7, 1) NULL,  
[Duration] [decimal](7, 1) NULL  
PRIMARY KEY CLUSTERED  
(  
[MiniProfilerId] ASC  
)WITH (PAD\_INDEX = OFF, STATISTICS\_NORECOMPUTE = OFF, IGNORE\_DUP\_KEY = ON, ALLOW\_ROW\_LOCKS = ON, ALLOW\_PAGE\_LOCKS = ON)  
)

GO

/\*\*\*\*\*\* Object: Table [dbo].[MiniProfilers] Script Date: 10/01/2013 13:50:33 \*\*\*\*\*\*/  
SET ANSI\_NULLS ON  
GO

SET QUOTED\_IDENTIFIER ON  
GO

CREATE TABLE [dbo].[MiniProfilers](  
[Id] [uniqueidentifier] NOT NULL,  
[Name] nvarchar NOT NULL,  
[Started] [datetime] NOT NULL,  
[MachineName] nvarchar NULL,  
[User] nvarchar NULL,  
[Level] [tinyint] NULL,  
[RootTimingId] [uniqueidentifier] NULL,  
[DurationMilliseconds] [decimal](7, 1) NOT NULL,  
[DurationMillisecondsInSql] [decimal](7, 1) NULL,  
[HasSqlTimings] [bit] NOT NULL,  
[HasDuplicateSqlTimings] [bit] NOT NULL,  
[HasTrivialTimings] [bit] NOT NULL,  
[HasAllTrivialTimings] [bit] NOT NULL,  
[TrivialDurationThresholdMilliseconds] [decimal](5, 1) NULL,  
[HasUserViewed] [bit] NOT NULL,  
PRIMARY KEY CLUSTERED  
(  
[Id] ASC  
)WITH (PAD\_INDEX = OFF, STATISTICS\_NORECOMPUTE = OFF, IGNORE\_DUP\_KEY = OFF, ALLOW\_ROW\_LOCKS = ON, ALLOW\_PAGE\_LOCKS = ON)  
)

GO

/\*\*\*\*\*\* Object: Table [dbo].[MiniProfilerSqlTimingParameters] Script Date: 10/01/2013 13:50:38 \*\*\*\*\*\*/  
SET ANSI\_NULLS ON  
GO

SET QUOTED\_IDENTIFIER ON  
GO

CREATE TABLE [dbo].[MiniProfilerSqlTimingParameters](  
[MiniProfilerId] [uniqueidentifier] NOT NULL,  
[ParentSqlTimingId] [uniqueidentifier] NOT NULL,  
[Name] nvarchar NOT NULL,  
[DbType] nvarchar NULL,  
[Size] [int] NULL,  
[Value] nvarchar NULL  
PRIMARY KEY CLUSTERED  
(  
[MiniProfilerId] ASC  
)WITH (PAD\_INDEX = OFF, STATISTICS\_NORECOMPUTE = OFF, IGNORE\_DUP\_KEY = ON, ALLOW\_ROW\_LOCKS = ON, ALLOW\_PAGE\_LOCKS = ON)  
)

GO

/\*\*\*\*\*\* Object: Table [dbo].[MiniProfilerSqlTimings] Script Date: 10/01/2013 13:50:40 \*\*\*\*\*\*/  
SET ANSI\_NULLS ON  
GO

SET QUOTED\_IDENTIFIER ON  
GO

CREATE TABLE [dbo].[MiniProfilerSqlTimings](  
[RowId] [int] IDENTITY(1,1) NOT NULL,  
[Id] [uniqueidentifier] NOT NULL,  
[MiniProfilerId] [uniqueidentifier] NOT NULL,  
[ParentTimingId] [uniqueidentifier] NOT NULL,  
[ExecuteType] [tinyint] NOT NULL,  
[StartMilliseconds] [decimal](7, 1) NOT NULL,  
[DurationMilliseconds] [decimal](7, 1) NOT NULL,  
[FirstFetchDurationMilliseconds] [decimal](7, 1) NULL,  
[IsDuplicate] [bit] NOT NULL,  
[StackTraceSnippet] nvarchar NOT NULL,  
[CommandString] nvarchar NOT NULL,  
PRIMARY KEY CLUSTERED  
(  
[RowId] ASC  
)WITH (PAD\_INDEX = OFF, STATISTICS\_NORECOMPUTE = OFF, IGNORE\_DUP\_KEY = OFF, ALLOW\_ROW\_LOCKS = ON, ALLOW\_PAGE\_LOCKS = ON)  
)

GO

/\*\*\*\*\*\* Object: Table [dbo].[MiniProfilerTimings] Script Date: 10/01/2013 13:50:44 \*\*\*\*\*\*/  
SET ANSI\_NULLS ON  
GO

SET QUOTED\_IDENTIFIER ON  
GO

CREATE TABLE [dbo].[MiniProfilerTimings](  
[RowId] [int] IDENTITY(1,1) NOT NULL,  
[Id] [uniqueidentifier] NOT NULL,  
[MiniProfilerId] [uniqueidentifier] NOT NULL,  
[ParentTimingId] [uniqueidentifier] NULL,  
[Name] nvarchar NOT NULL,  
[Depth] [smallint] NOT NULL,  
[StartMilliseconds] [decimal](7, 1) NOT NULL,  
[DurationMilliseconds] [decimal](7, 1) NOT NULL,  
[DurationWithoutChildrenMilliseconds] [decimal](7, 1) NOT NULL,  
[SqlTimingsDurationMilliseconds] [decimal](7, 1) NULL,  
[IsRoot] [bit] NOT NULL,  
[HasChildren] [bit] NOT NULL,  
[IsTrivial] [bit] NOT NULL,  
[HasSqlTimings] [bit] NOT NULL,  
[HasDuplicateSqlTimings] [bit] NOT NULL,  
[ExecutedReaders] [smallint] NOT NULL,  
[ExecutedScalars] [smallint] NOT NULL,  
[ExecutedNonQueries] [smallint] NOT NULL,  
PRIMARY KEY CLUSTERED  
(  
[RowId] ASC  
)WITH (PAD\_INDEX = OFF, STATISTICS\_NORECOMPUTE = OFF, IGNORE\_DUP\_KEY = OFF, ALLOW\_ROW\_LOCKS = ON, ALLOW\_PAGE\_LOCKS = ON)  
)

GO

Thanks
