IF NOT EXISTS (SELECT * FROM SYSCOLUMNS INNER JOIN SYSOBJECTS ON SYSOBJECTS.id = SYSCOLUMNS.id 
               WHERE SYSCOLUMNS.NAME = 'SUBEID' AND SYSOBJECTS.name = 'ITS')
ALTER TABLE ITS ADD SUBEID int NULL
GO

IF EXISTS (SELECT name FROM sysindexes 
      WHERE name = 'IX_ITS_GTIN_SN')
DROP INDEX [IX_ITS_GTIN_SN] ON [dbo].[ITS]
GO

CREATE UNIQUE NONCLUSTERED INDEX [IX_ITS_GTIN_SN] ON [dbo].[ITS]
(
	[GTIN] ASC,
	[SN] ASC,
	[SUBEID] 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, FILLFACTOR = 90) ON [PRIMARY]
GO


