
/* drop existing PK constraint, indexes */

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

GO

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

ALTER TABLE [dbo].[DT501] ADD  CONSTRAINT [PK_DT501] PRIMARY KEY CLUSTERED 
(
	[DI024161] ASC,
	[DI024162] 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].[DT501] 
(
	[DI024161] ASC,
	[DI024162] ASC
)
INCLUDE ( [DI028072]) 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 [FK_DT406] ON [dbo].[DT501] 
(
	[DI024162] ASC
)
INCLUDE ( [DI024161],
[DI028072]) 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
