How to rename an index in SQL Server

You can find the names of all indexes on user tables in the database using this code:

USE Database_name
SELECT s.name table_name, i.name index_name
FROM sysobjects s
left join sysindexes i on i.id = s.id
WHERE s.xtype = 'U'
ORDER BY table_name

To rename an index in SQL Server:

USE Database_name;
GO
EXEC sp_rename N'Schema_name.Table_name.Index_name_old', N'Index_name_new', N'INDEX';
GO

You can rename an index in SQL Server Management Studio by right-clicking on the index and selecting "Rename":

If the post helped you, please share it:
Pin It

Leave a Reply

You can use these HTML tags

<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code class="" title="" data-url=""> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong> <pre class="" title="" data-url=""> <span class="" title="" data-url="">