diff --git a/src/Microsoft.SqlTools.ServiceLayer/QueryExecution/QueryExecutionService.cs b/src/Microsoft.SqlTools.ServiceLayer/QueryExecution/QueryExecutionService.cs index b65808cc..7f307fee 100644 --- a/src/Microsoft.SqlTools.ServiceLayer/QueryExecution/QueryExecutionService.cs +++ b/src/Microsoft.SqlTools.ServiceLayer/QueryExecution/QueryExecutionService.cs @@ -154,7 +154,7 @@ namespace Microsoft.SqlTools.ServiceLayer.QueryExecution Query newQuery = await CreateAndActivateNewQuery(executeParams, requestContext); // Execute the query -- asynchronously - await ExecuteAndCompleteQuery(executeParams, requestContext, newQuery); + ExecuteAndCompleteQuery(executeParams, requestContext, newQuery); } /// @@ -369,6 +369,12 @@ namespace Microsoft.SqlTools.ServiceLayer.QueryExecution return null; } + // Send the result stating that the query was successfully started + await requestContext.SendResult(new QueryExecuteResult + { + Messages = newQuery.Batches.Length == 0 ? SR.QueryServiceCompletedSuccessfully : null + }); + return newQuery; } catch (Exception e) @@ -378,7 +384,7 @@ namespace Microsoft.SqlTools.ServiceLayer.QueryExecution } } - private static async Task ExecuteAndCompleteQuery(QueryExecuteParams executeParams, RequestContext requestContext, Query query) + private static void ExecuteAndCompleteQuery(QueryExecuteParams executeParams, RequestContext requestContext, Query query) { // Skip processing if the query is null if (query == null) @@ -451,18 +457,6 @@ namespace Microsoft.SqlTools.ServiceLayer.QueryExecution // Launch this as an asynchronous task query.Execute(); - - // Send back a result showing we were successful - string messages = null; - if (query.Batches.Length == 0) - { - // If there were no batches to execute, send back an informational message that the commands were completed successfully - messages = SR.QueryServiceCompletedSuccessfully; - } - await requestContext.SendResult(new QueryExecuteResult - { - Messages = messages - }); } private async Task SaveResultsHelper(SaveResultsRequestParams saveParams,