Hey guys, I am trying to work on the upgrade component in our program. This requires changing an index's name
EXEC sp_rename N'Sig_Summary1Index.IX_Sig_Summary1Index_StartTime',
N'Sig_Summary3Index.IX_Sig_Summary1Index1_StartTime', N'INDEX';
(we need to remain compatible with SQL SERVER 2005)
and then check if it exists in the same transaction:
IF NOT EXISTS
( SELECT *
FROM sys.indexes
WHERE object_id = OBJECT_ID(N'[dbo].[Sig_Summary1Index]' )
AND name = N'[IX_Sig_Summary1Index1_StartTime]')
CREATE CLUSTERED INDEX [IX_Sig_Summary1Index1_StartTime]
ON [dbo].[Sig_Summary1Index] (
[StartTime] 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 = 95
)
ON [PRIMARY]
This WILL try to create the index. :(
somehow, during the transaction the sys.indexes
table is not updated yet.
Is there any other way to avoid creating this index?
Edit: Is there any way i can "flush" the sys tables to update? Insert the records manually? do something so that the "check" will not be changed?