Incorrect syntax near 'RESAMPLE'. [SQLSTATE 42000] #422

Kazi, Imran 1 Reputation point
2020-10-07T11:13:31.32+00:00

I am running olahallengren IndexOptimize - USER_DATABASES

Description of the issue

Running job "IndexOptimize - USER_DATABASES" and failing with the following error

UPDATE STATISTICS [DatabaseName].[dbo].[tableName] [indexName] RESAMPLE [SQLSTATE 01000]
Msg 50000, Sev 16, State 1, Line 152 : Msg 102, Incorrect syntax near 'RESAMPLE'. [SQLSTATE 42000]

SQL Server version and edition

Microsoft SQL Server 2019 (RTM-CU6) (KB4563110) - 15.0.4053.23 (X64) Jul 25 2020 11:26:55 Copyright (C) 2019 Microsoft Corporation Enterprise Edition: Core-based Licensing (64-bit) on Windows Server 2019 Datacenter 10.0 (Build 17763: ) (Hypervisor)

Version of the script
Check the header of the stored procedure

cannot determine.
What command are you executing?

EXECUTE dbo.IndexOptimize
@databases = 'DatabaseName',
@FragmentationLow = NULL,
@FragmentationMedium = 'INDEX_REORGANIZE,INDEX_REBUILD_ONLINE,INDEX_REBUILD_OFFLINE',
@FragmentationHigh = 'INDEX_REBUILD_ONLINE,INDEX_REBUILD_OFFLINE',
@FragmentationLevel1 = 5,
@FragmentationLevel2 = 15,
@UpdateStatistics = 'ALL',
@OnlyModifiedStatistics = 'Y',
@indexes = 'ALL_INDEXES, -db.Staging.KO_%'

What output are you getting?
Incorrect syntax near 'RESAMPLE'

SQL Server
SQL Server
A family of Microsoft relational database management and analysis systems for e-commerce, line-of-business, and data warehousing solutions.
13,967 questions
{count} votes

4 answers

Sort by: Most helpful
  1. tibor_karaszi@hotmail.com 4,311 Reputation points
    2020-10-07T12:09:57.127+00:00

    You have an invalid command. The correct command need WITH before the word RESAMPLE. There are two possibilities:

    Somebody modified Ola's procedure and introduced the bug.

    The bug was in Ola's procedure from the beginning.

    In any case, I suggest you update the procedures by downloading a current version of his maintenance script. If the problem persist, then you need to contact Ola and see if he can fix the bug.

    The problem is not in SQL Server.

    (I believe that Ola's stuff is on GitHub, so if you are good at T-SQL coding, you can possibly fix this yourself as a code-bransch at GitHub.)

    1 person found this answer helpful.
    0 comments No comments

  2. Tom Phillips 17,736 Reputation points
    2020-10-07T12:57:39.177+00:00

    There is logic in the current code to add "WITH" in front of RESAMPLE. Please make sure you are using the most current version of the scripts.

    0 comments No comments

  3. AmeliaGu-MSFT 13,981 Reputation points Microsoft Vendor
    2020-10-08T02:25:10.44+00:00

    Hi @Kazi, Imran ,

    According to this thread, this bug is fixed in the 25 Sep 2016 release. Please try to use the latest version script.

    Best Regards,
    Amelia


    If the answer is helpful, please click "Accept Answer" and upvote it.
    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    0 comments No comments

  4. kazi Imran 1 Reputation point
    2020-10-12T16:08:05.12+00:00

    In my case it was resolved as we have excluded columnstore index

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.