Hello :
Trying to understand what i am doing wrong here.
I execute a SQL script to drop an index if it exists and then create it in the same script.
I execute in SSMs and I see the index.
I use the same script in SQL Agent job as a step and i get success result but do not see the index.
What am i doing wrong here?
IF EXISTS (SELECT * FROM sys.indexes WHERE object_id = OBJECT_ID(N'[dbo].
') AND name = N'index_INDEX')
DROP INDEX [index_INDEX] ON [dbo].[tablename]
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
IF NOT EXISTS (SELECT * FROM sys.indexes WHERE object_id = OBJECT_ID(N'[dbo].[tablename') AND name = N'index_INDEX')
CREATE NONCLUSTERED INDEX [index_INDEX] ON [dbo].[tablename]
(
[TAIL_NUMBER] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, SORT_IN_TEMPDB = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
GO
SET ANSI_PADDING ON
GO