0
Is there any way to use a Script check if an index already exists in a table?
I got the following script that generates an index in a table:
CREATE NONCLUSTERED INDEX [meu_indice] ON [dbo].[MinhaTabela]
(
[Id] ASC,
[Chave_Id] 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)
GO
Only that as I already created the index in the table, if I try to run the script gives error saying that the index has already been created.
Would have some way to check if the index already exists and only create if it does not exist?
You could put the complete script using the code I passed?
– Érik Thiago
Even if I have more than one index as in the code I sent? Type Id1 and Id2? Something else, could you put it both ways? I think it would be nice in the answer to have both forms!
– Érik Thiago