Closed TheAceMan closed 2 years ago
Quote from the discussion on the post itself: We have a few Table Valued functions in which return an "at"TableName table variable with a PRIMARY KEY defined in it. This script will try to include these, and then fails...
"FAILED : 1914Index cannot be created on object 'dbo.functionnamehere' because the object is not a user table or view."
CREATE FUNCTION [dbo].[xxxxxxxxxxxxxxx] () RETURNS @yyyyyyyyyyyyyyyyyyyyyyyyyyyy TABLE ([id] INT IDENTITY(1, 1) PRIMARY KEY NOT NULL,
This issue fixed. I changed the join between sys.indexes and index_physical_stats to inner join instead of left join while the index is on function it will not have physical stats information therefore those indexes will not be listed.
fix committed to main branch
The procedure attempts to rebuild indexes on table-valued function. These should be ignored or skipped.
Attempting to run: ALTER INDEX [PK_indexName] ON [dbo].[functionName] REBUILD WITH(ONLINE=ON,MAXDOP=1);
Error: FAILED : 1914 Index cannot be created on object 'dbo.stfGetOrgUnitIdsBySchedGroupOrOrgUnit' because the object is not a user table or view.