
/* drop existing PK constraint, indexes */

IF  EXISTS (SELECT * FROM sys.indexes WHERE object_id = OBJECT_ID(N'[dbo].[DT461]') AND name = N'PID461DT461')
ALTER TABLE [dbo].[DT461] DROP CONSTRAINT [PID461DT461]

GO

/* create clustered index first, PK constraint second, non-clustered indexes last */

CREATE UNIQUE CLUSTERED INDEX [HPR+PARENT+PR] ON [dbo].[DT461] 
(
	[DI001052] ASC,
	[DI001003] ASC,
	[DI001004] ASC,
	[DI001001] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, SORT_IN_TEMPDB = OFF, IGNORE_DUP_KEY = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]

GO

ALTER TABLE [dbo].[DT461] ADD  CONSTRAINT [PK_DT461] PRIMARY KEY NONCLUSTERED 
(
	[DI001001] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, SORT_IN_TEMPDB = OFF, IGNORE_DUP_KEY = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]

GO

CREATE UNIQUE NONCLUSTERED INDEX [PK_covering_query] ON [dbo].[DT461] 
(
	[DI001001] ASC
)
INCLUDE ( [DI001003],
[DI001004],
[DI001052]) WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, SORT_IN_TEMPDB = OFF, IGNORE_DUP_KEY = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]

GO

CREATE NONCLUSTERED INDEX [RECURSION_PARENT] ON [dbo].[DT461] 
(
	[DI001003] ASC
)
INCLUDE ( [DI001001],
[DI001004],
[DI001052]) WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, SORT_IN_TEMPDB = OFF, IGNORE_DUP_KEY = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]

GO

CREATE NONCLUSTERED INDEX [RECURSION_PARENT_TASK] ON [dbo].[DT461] 
(
	[DI001003] ASC,
	[DI001004] ASC
)
INCLUDE ( [DI001001],
[DI001052]) WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, SORT_IN_TEMPDB = OFF, IGNORE_DUP_KEY = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]

GO
