You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Description:
I am facing an error when trying to deprovision SyncProvision.ScopeInfo and SyncProvision.ScopeInfoClient:
incorrect syntax near the keyword 'IF'. drop table if exists
The DROP TABLE IF EXISTS syntax is supported starting from SQL Server 2016 (13.x) and later versions. For older versions of SQL Server, an alternative approach is required.
Proposed Solution:
Modify the methods GetDropScopeInfoTableCommand and GetDropScopeInfoClientTableCommand in SqlScopeBuilder to use a compatible query for older SQL Server versions.
Here is an equivalent query that works in older versions of SQL Server:
IF OBJECT_ID('dbo.TableName', 'U') IS NOT NULLDROPTABLEdbo.TableName;
I will make a pull request with the proposed fix.
Pull Request Description
Title: Fix for DROP TABLE IF EXISTS compatibility in older SQL Server versions
Description:
This pull request addresses the issue with the DROP TABLE IF EXISTS syntax, which is not supported in SQL Server versions earlier than 2016. The methods GetDropScopeInfoTableCommand and GetDropScopeInfoClientTableCommand in SqlScopeBuilder are updated to use a compatible query for older versions of SQL Server.
Changes:
Modified GetDropScopeInfoClientTableCommand in SqlScopeBuilder to:
publicoverride DbCommand GetDropScopeInfoClientTableCommand(DbConnectionconnection,DbTransactiontransaction){vartableName=$"{this.ScopeInfoTableName.Unquoted().Normalized().ToString()}_client";vartableWithSchema=$"[dbo].[{tableName}]";varcommand= connection.CreateCommand();
command.Transaction =transaction;
command.CommandText =$"IF OBJECT_ID('{tableWithSchema}', 'U') IS NOT NULL "+$"DROP TABLE {tableWithSchema};";returncommand;}
Modified GetDropScopeInfoTableCommand in SqlScopeBuilder to:
publicoverride DbCommand GetDropScopeInfoTableCommand(DbConnectionconnection,DbTransactiontransaction){vartableName=this.ScopeInfoTableName.Unquoted().Normalized().ToString();vartableWithSchema=$"[dbo].[{tableName}]";varcommand= connection.CreateCommand();
command.Transaction =transaction;
command.CommandText =$"IF OBJECT_ID('{tableWithSchema}', 'U') IS NOT NULL "+$"DROP TABLE {tableWithSchema};";returncommand;}}
By implementing these changes, the library will be compatible with older versions of SQL Server.
I have tested these changes on SQL Server versions earlier than 2016 and confirmed that the issue is resolved.
The text was updated successfully, but these errors were encountered:
Description:
I am facing an error when trying to deprovision
SyncProvision.ScopeInfo
andSyncProvision.ScopeInfoClient
:The
DROP TABLE IF EXISTS
syntax is supported starting from SQL Server 2016 (13.x) and later versions. For older versions of SQL Server, an alternative approach is required.Proposed Solution:
Modify the methods
GetDropScopeInfoTableCommand
andGetDropScopeInfoClientTableCommand
inSqlScopeBuilder
to use a compatible query for older SQL Server versions.Here is an equivalent query that works in older versions of SQL Server:
I will make a pull request with the proposed fix.
Pull Request Description
Title: Fix for DROP TABLE IF EXISTS compatibility in older SQL Server versions
Description:
This pull request addresses the issue with the
DROP TABLE IF EXISTS
syntax, which is not supported in SQL Server versions earlier than 2016. The methodsGetDropScopeInfoTableCommand
andGetDropScopeInfoClientTableCommand
inSqlScopeBuilder
are updated to use a compatible query for older versions of SQL Server.Changes:
GetDropScopeInfoClientTableCommand
inSqlScopeBuilder
to:GetDropScopeInfoTableCommand
inSqlScopeBuilder
to:By implementing these changes, the library will be compatible with older versions of SQL Server.
I have tested these changes on SQL Server versions earlier than 2016 and confirmed that the issue is resolved.
The text was updated successfully, but these errors were encountered: