diff --git a/src/Microsoft.SqlTools.ManagedBatchParser/ReliableConnection/SqlConnectionHelperScripts.cs b/src/Microsoft.SqlTools.ManagedBatchParser/ReliableConnection/SqlConnectionHelperScripts.cs index 079861ae..1b719e4c 100644 --- a/src/Microsoft.SqlTools.ManagedBatchParser/ReliableConnection/SqlConnectionHelperScripts.cs +++ b/src/Microsoft.SqlTools.ManagedBatchParser/ReliableConnection/SqlConnectionHelperScripts.cs @@ -55,9 +55,13 @@ SELECT @filepath AS FilePath SELECT [name], [description], [endpoint], [protocol_desc] FROM .[sys].[dm_cluster_endpoints] END TRY BEGIN CATCH -DECLARE @endpoint VARCHAR(max) -select @endpoint = CONVERT(VARCHAR(max),SERVERPROPERTY('ControllerEndpoint')) +DECLARE @endpoint VARCHAR(MAX) +SELECT @endpoint = CONVERT(VARCHAR(MAX),SERVERPROPERTY('ControllerEndpoint')) +-- If the endpoint is empty/null then return 0 rows (we don't have any cluster endpoints) +IF @endpoint <> '' SELECT 'controller' AS name, 'Cluster Management Service' AS description, @endpoint as endpoint, SUBSTRING(@endpoint, 0, CHARINDEX(':', @endpoint)) +ELSE +SELECT TOP 0 '' END CATCH "; public const string GetHostInfo = @"SELECT [host_platform], [host_distribution], [host_release], [host_service_pack_level], [host_sku], [os_language_version] FROM sys.dm_os_host_info"; diff --git a/src/Microsoft.SqlTools.ServiceLayer/Migration/MigrationService.cs b/src/Microsoft.SqlTools.ServiceLayer/Migration/MigrationService.cs index aa9b03f9..20a7beba 100644 --- a/src/Microsoft.SqlTools.ServiceLayer/Migration/MigrationService.cs +++ b/src/Microsoft.SqlTools.ServiceLayer/Migration/MigrationService.cs @@ -119,7 +119,6 @@ namespace Microsoft.SqlTools.ServiceLayer.Migration await ConnectionService.Connect(connectParams); var connection = await ConnectionService.Instance.GetOrOpenConnection(randomUri, ConnectionType.Default); - var serverInfo = ReliableConnectionHelper.GetServerVersion(connection); var hostInfo = ReliableConnectionHelper.GetServerHostInfo(connection); @@ -136,8 +135,8 @@ namespace Microsoft.SqlTools.ServiceLayer.Migration }; var db = SqlAssessmentService.GetDatabaseLocator(server, connection.Database); - - var results = await GetAssessmentItems(server); + var connectionString = ConnectionService.BuildConnectionString(connInfo.ConnectionDetails); + var results = await GetAssessmentItems(server, connectionString); var result = new MigrationAssessmentResult(); result.Items.AddRange(results); await requestContext.SendResult(result); @@ -179,9 +178,9 @@ namespace Microsoft.SqlTools.ServiceLayer.Migration } } - internal async Task> GetAssessmentItems(SqlObjectLocator target) + internal async Task> GetAssessmentItems(SqlObjectLocator target, string connectionString) { - DmaEngine engine = new DmaEngine(target); + DmaEngine engine = new DmaEngine(connectionString); var assessmentResults = await engine.GetTargetAssessmentResultsList(); var result = new List();