October 11, 2010 at 12:22 am
Comments posted to this topic are about the item Fix Index Naming
October 11, 2010 at 3:00 am
I think some of the functions used within the script are missing from the script. Hopefully these can be linked too.
October 11, 2010 at 3:06 am
Did you download the install script from below. or did you copy the sql code. I tried both install scripts on a server, and none of them failed with missing table value functions
-- -- # IMPORTANT!!!
-- #
-- # Because of the rather lengthy install script, I am only showing the
-- # script for display. It won't install, because of missing table value
-- # functions. The version I have shown is the 2008 version
-- #
-- # You can download a complete install script here.
-- # 2005 version - http://files.soendergaard.info/Install_spFixIndexNaming_V2005.sql
-- # 2008 version - http://files.soendergaard.info/Install_spFixIndexNaming_V2008.sql
October 11, 2010 at 3:10 am
Thanks, I had copied the SQL from the webpage and I didn't see those links earlier, thanks 🙂
April 18, 2014 at 1:43 pm
Hi Michael,
These scripts have been invaluable to me in the past. I am trying to use them for the first time in a couple of years, and I am running into an odd error when it tries to rename :
Object '[dbo].[dtproperties].[pk_dtproperties]' does not exist or is not a valid object for this operation.
I think the problem is that it is trying to rename the PK for dtproperties, which is otherwise considered a system table despite being in the dbo schema:
EXECUTE sp_rename '[dbo].[dtproperties].[pk_dtproperties]','PK_dtproperties_a', 'index'
Have idea?
I tried to see if it was a system-level data modification that was being blocked, as well, by modifying this config setting:
sp_configure 'allow updates', 1
RECONFIGURE WITH OVERRIDE;
... which didn't work.
Also, would be for taking patches?
I think in this case there is a bug, where you should exclude tables matching the following queries:
select * from sys.tables t where t.is_ms_shipped = 1
select * from sys.key_constraints kc where kc.is_ms_shipped = 1
What I would really love is two features:
For the latter example, I imagine the code looking like this internally:
DECLARE @UniqueID uniqueidentifier = NEWID();
DECLARE @TempRenameCommand nvarchar(max);
DECLARE @FinalRenameCommand nvarchar(max);
SET @TempRenameCommand = 'sp_rename ''[dbo].[dtproperties].[pk_dtproperties]'',''PK_dtproperties_' + CAST(@UniqueID as nvarchar(50)) + ''', ''index''';
--EXECUTE @TempRenameCommand
SET @FinalRenameCommand = 'sp_rename ''[dbo].[dtproperties].PK_dtproperties_' + CAST(@UniqueID as nvarchar(50)) + ''',''PK_dtproperties'', ''index''';
--EXECUTE @FinalRenameCommand
--EXECUTE sp_rename '[dbo].[dtproperties].[pk_dtproperties]','PK_dtproperties', 'index'
print @TempRenameCommand;
print @FinalRenameCommand;
I'll make two offers here:
Either one works for me!
April 18, 2014 at 2:28 pm
Here are my patches:
Uniquifier = ROW_NUMBER() OVER (PARTITION BY NewName ORDER BY SchemaName, OldName, NewName)
Note I added OldName, in order to prevent spurious flipping back and forth.
Test parameter:
@IndexConvention = 'IX_%INDEX_TYPE%_%UNIQUE_INDEX%%FILTERED_INDEX%_%TABLE_NAME%_%INDEX_COLUMNS%'
FROM
sys.indexes i
JOIN sys.tables t ON
i.object_id = t.object_id AND
i.type_desc IN ('CLUSTERED', 'NONCLUSTERED', 'XML', 'SPATIAL')
AND t.is_ms_shipped = 0
Note I added AND t.is_ms_shipped = 0 to exclude IsMsShipped objects.
May 18, 2016 at 7:04 am
Thanks for another good script.
April 17, 2017 at 9:58 am
What would be the possible naming convention for a Filtered Index?
FNCI !!
Thanks,
Santhosh
Viewing 8 posts - 1 through 7 (of 7 total)
You must be logged in to reply to this topic. Login to reply