I am trying to rename an index and getting an error:
Error: Explicit @objtype ‘idx_FinData20’ is unrecognized.
I can see both the table and index exist. Then what is the problem
IF ( EXISTS (SELECT * FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA = 'dbo' AND TABLE_NAME ='FinData2000_1_old')) BEGIN EXEC sp_rename 'FinData2000_1_old.idx_FinData2000_1' , 'idx_FinData2000_1', 'idx_FinData20 00_1_old' end
Advertisement
Answer
First – your syntax is wrong. You need only two arguments, first should be table_name.old_name
and second one is just new name
.
Second – you have an extra space in your new index name which breaks the script.
EXEC sp_rename 'FinData2000_1_old.idx_FinData2000_1' , 'idx_FinData2000_1_old'