sql-server-maintenance-solution icon indicating copy to clipboard operation
sql-server-maintenance-solution copied to clipboard

Index Optimize & Update Stats Error on external tables

Open NGC-MHESS opened this issue 4 years ago • 4 comments

Msg 46519, Update Statistics are not supported with external tables. [SQLSTATE 42000] (Error 50000)

SQL Server 2019 Developer Edition

Version of the script 2020-01-26 14:06:53

What command are you executing? EXECUTE dbo.IndexOptimize @Databases = 'USER_DATABASES', @FragmentationLow = NULL, @FragmentationMedium = NULL, @FragmentationHigh = NULL, @UpdateStatistics = 'ALL', @OnlyModifiedStatistics = 'N', @LogToTable='Y'

What output are you getting? Msg 46519, Update Statistics are not supported with external tables. [SQLSTATE 42000] (Error 50000)

NGC-MHESS avatar Jun 07 '21 17:06 NGC-MHESS

I am getting this issue as well. Other than excluding the external tables in the job definition, are there any other options?

heaivilinn avatar Dec 13 '21 15:12 heaivilinn

While trying to figure this out, found this: Create Statistics

Essentially, UPDATE STATISTICS isn't supported. If you want to rebuild them, it must be a DROP and CREATE.

So, I'd see two options here:

  1. Ignore External Tables
  2. Drop and Create

Guess the question is, what would we like to see from an update to the code? Do we want to provide both options or just 1? Could see a new parameter '@ExternalTables' with options for 'RECREATE' or 'IGNORE' with the default being 'RECREATE'.

Thoughts?

heaivilinn avatar Feb 21 '22 16:02 heaivilinn

@olahallengren , I have a script I am testing to resolve these issues. I am unable to publish my branch and/or create a pull request for the changes. If my code works, what is the process for getting it reviewed and put into the main repository?

heaivilinn avatar Feb 23 '22 22:02 heaivilinn

I've submitted pull request to resolve this issue:

https://github.com/olahallengren/sql-server-maintenance-solution/pull/645

heaivilinn avatar May 11 '22 20:05 heaivilinn