web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

No record found.

News and Announcements icon
Community site session details

Community site session details

Session Id :
Small and medium business | Business Central, N...
Suggested Answer

Upgrade Sync Process - NAV 2013 to Nav 2018

(1) ShareShare
ReportReport
Posted on by 68
Hi Everyone, 
 
        While doing the Upgrade process from Nav 2013 to Nav 2018, i am getting an error, during the sync Process, the error details are 
 
PS C:\WINDOWS\system32> Sync-NAVTenant -ServerInstance DynamicsNAV110
Sync-NAVTenant : The following SQL error was unexpected:
Incorrect syntax near '$7'.
At line:1 char:1
+ Sync-NAVTenant -ServerInstance DynamicsNAV110
+ ~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (0:Int32) [Sync-NAVTenant], NavCommandException
    + FullyQualifiedErrorId : MicrosoftDynamicsNavServer$DynamicsNAV110,Microsoft.Dynamics.Nav.Management.Cmdlets.SyncNavTenant
 
Error Log Details are 
 
Server instance: DynamicsNAV110 Tenant ID: <ii>default</ii> <ii>Session type: UnknownClient Session ID: 55 User: Vishu\SynergyIT Type: Microsoft.Dynamics.Nav.Types.Exceptions.NavSqlException ErrorNumber: 102 SuppressMessage: False DiagnosticsSuppress: False SuppressExceptionCreatedEvent: False FatalityScope: None Message: <ii>The following SQL error was unexpected: Incorrect syntax near '$7'. SQL statement: DECLARE @StatisticsToDrop NVARCHAR(MAX); SELECT @StatisticsToDrop = COALESCE(@StatisticsToDrop +', ', '') + '[Cape Gourmet Seafood Co Ltd$Cust_ Ledger Entry].'+ s.name FROM sys.stats AS s INNER JOIN sys.stats_columns AS sc ON (s.stats_id = sc.stats_id AND sc.object_id = s.object_id) INNER JOIN sys.all_columns AS c ON (c.column_id = sc.column_id AND c.object_id = s.object_id) WHERE s.object_id = OBJECT_ID('Cape Gourmet Seafood Co Ltd$Cust_ Ledger Entry') AND (c.name = 'Customer Posting Group' OR c.name = 'Salesperson Code' OR c.name = 'No_ Series' ) IF @@ROWCOUNT > 0 BEGIN SET @StatisticsToDrop = CONCAT('drop statistics ', @StatisticsToDrop) EXECUTE sp_executesql @StatisticsToDrop END StackTrace: at System.Environment.GetStackTrace(Exception e, Boolean needFileInfo) at System.Environment.get_StackTrace() at Microsoft.Dynamics.Nav.Runtime.NavSqlConnection.ThrowNavSqlException(SqlExceptionAdapter exceptionAdapter, String commandText, Boolean isLastExceptionARollbackCause, Boolean logExceptions) at Microsoft.Dynamics.Nav.Runtime.NavSqlConnection.<>c__DisplayClass104_0`1.<ExecuteFunction>b__0() at Microsoft.Dynamics.Nav.Diagnostic.NavDiagnostics.SendTraceTagOnThreshold[T](String tag, Category category, Verbosity verbosity, Int32 threshold, Func`1 action, String message, Object[] parameters) at Microsoft.Dynamics.Nav.Runtime.NavSqlConnection.ExecuteFunctionWithTrace[T](EventTask task, Func`1 function, String commandText) at Microsoft.Dynamics.Nav.Runtime.NavSqlCommand.ExecuteNonQueryImp() at Microsoft.Dynamics.Nav.Runtime.NavSqlBatchedCommand.ExecuteNonQuery() at Microsoft.Dynamics.Nav.Runtime.NavSqlDdlCommands.ExecuteNonQuery() at Microsoft.Dynamics.Nav.Runtime.NavSqlDdlCommands.DropStatisticsOnFields(NCLMetaTable table, ICollection`1 fields, Int32 companyToken, NavAppTableContext tableContext) at Microsoft.Dynamics.Nav.Runtime.NavSqlDdlCommands.AlterTableFinalize(NavDatabase database, NavSqlTableAndChange tableAndChange, Int32 companyToken, SyncMode syncMode, TablePartitionMetadata tablePartitionMetadata) at Microsoft.Dynamics.Nav.Runtime.NavSqlDdlCommands.PrepareNewTable(NavDatabase database, NavSqlTableAndChange tableAndChange, Int32 companyToken, SyncMode syncMode) at Microsoft.Dynamics.Nav.Runtime.NavSqlDatabaseSync.SyncAllTables(IEnumerable`1 tableChanges, RebuildAction rebuildAction, Int32[] companyTokens, SyncMode syncMode, Int32 syncStepNo, Int32 totalSteps, NavAppSyncOptions appSyncOptions, Boolean perTable) at Microsoft.Dynamics.Nav.Runtime.NavSqlDatabaseSync.SynchronizeTableChanges(NavSession session, IEnumerable`1 tableChanges, Int32[] companyTokens, SyncMode syncMode, Boolean isUpgradeTableSynchronization, Boolean perTable) at Microsoft.Dynamics.Nav.Runtime.NavSqlDatabaseSync.PerformSync(NavSession session, IEnumerable`1 tableChangesToSynchronize, GetTableSyncSetup getTableSyncSetup, Int32[] companyTokens, SyncMode syncMode, Boolean perTable) at Microsoft.Dynamics.Nav.Runtime.NavSqlDatabaseSync.SynchronizeTenantDatabase(NavSession session, SyncMode syncMode, Boolean perTable, Boolean sortingPropertiesDifferent, Boolean sharedSchema) at Microsoft.Dynamics.Nav.Runtime.NavSqlDatabaseSync.<>c__DisplayClass85_0.<EnsureDatabaseInSync>b__1(NavTenant tenant, NavSession systemSession) at Microsoft.Dynamics.Nav.Runtime.NavTenant.Microsoft.Dynamics.Nav.Runtime.ITenantSessionHandler.RunTenantActionInSystemSession(Action`2 action, Boolean throwExceptions, Boolean useCurrentCulture, Boolean allowAppsDisabledMode) at Microsoft.Dynamics.Nav.Runtime.NavSqlDatabaseSync.EnsureDatabaseInSync(SyncMode syncMode, Boolean perTable, Boolean sharedSchema) at Microsoft.Dynamics.Nav.Runtime.NavSqlDatabaseSync.<>c__DisplayClass108_0.<StartProcessIfNotAlreadyStarted>b__0() at Microsoft.Dynamics.Nav.Runtime.NavTaskFactory.<>c__DisplayClass1_0.<RunTask>b__0() at System.Threading.Tasks.Task.Execute() at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx) at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx) at System.Threading.Tasks.Task.ExecuteWithThreadLocal(Task& currentTaskSlot) at System.Threading.Tasks.Task.ExecuteEntry(Boolean bPreventDoubleExecution) at System.Threading.ThreadPoolWorkQueue.Dispatch()</ii> HResult: -2146233088 ---------------------------------- Type: System.Data.SqlClient.SqlException ClientConnectionId: f3f9b8d4-8206-44a4-8c25-851cede6a6df Class: 15 LineNumber: 1 Number: 102 Server: VISHU State: 1 Source: .Net SqlClient Data Provider ErrorCode: -2146232060 Message: <ii>Incorrect syntax near '$7'.</ii> StackTrace: at System.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection, Action`1 wrapCloseInAction) at System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj, Boolean callerHasConnectionLock, Boolean asyncClose) at System.Data.SqlClient.TdsParser.TryRun(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj, Boolean& dataReady) at System.Data.SqlClient.SqlCommand.RunExecuteNonQueryTds(String methodName, Boolean async, Int32 timeout, Boolean asyncWrite) at System.Data.SqlClient.SqlCommand.InternalExecuteNonQuery(TaskCompletionSource`1 completion, String methodName, Boolean sendToPipe, Int32 timeout, Boolean& usedCache, Boolean asyncWrite, Boolean inRetry) at System.Data.SqlClient.SqlCommand.ExecuteNonQuery() at Microsoft.Dynamics.Nav.Runtime.NavSqlConnection.<>c__DisplayClass104_0`1.<ExecuteFunction>b__0() HResult: -2146232060 </ii> 
 
 
I have the same question (0)
  • Suggested answer
    Assisted by AI
    OussamaSabbouh Profile Picture
    11,792 Super User 2026 Season 1 on at
    Hello,
    This error is usually caused by a bad old SQL statistic/index name on a company table, not by Sync-NAVTenant itself. During sync, NAV tries to drop statistics on tables like Cust_ Ledger Entry, and one of those SQL objects seems to be named something like $7, which makes the generated SQL fail with “Incorrect syntax near '$7'”. So the practical fix is to check the affected company tables in SQL Server, find any odd statistics/index names, script them if needed, drop the problematic ones, and rerun Sync-NAVTenant. Also make sure the upgrade steps are being followed in the correct Microsoft order, because syncing at the wrong stage can make these schema issues surface more badly.
     
    Regards,
    Oussama Sabbouh

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Stars!

Congratulations to our 2025 Community Spotlights

Thanks to all of our 2025 Community Spotlight stars!

Leaderboard > Small and medium business | Business Central, NAV, RMS

#1
OussamaSabbouh Profile Picture

OussamaSabbouh 1,822 Super User 2026 Season 1

#2
YUN ZHU Profile Picture

YUN ZHU 1,136 Super User 2026 Season 1

#3
Dhiren Nagar Profile Picture

Dhiren Nagar 956 Super User 2026 Season 1

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans