IT Management Suite

 View Only

 SQL Report not working if column names has spaces

Rufus Swart's profile image
Rufus Swart posted Jun 25, 2021 03:26 AM
Hi,

How to overcome the issue where SQL report won't save if any column or subquery column has a space in the name:


Logs:

DataSourceWrapper.Validate

An unexpected SQL error occurred when retrieving the schema from the RawSqlDataSource.
   [Altiris.DataSource.Exceptions.DataSourceSchemaException @ Altiris.Reporting.DataSource]
   at Altiris.Reporting.DataSource.RawSqlDataSource.RunSchema()
   at Altiris.NS.MvcWeb.Models.DataSourceWrapper.Run(Boolean bGetResults, String& sErrorMessage, DataTable& dtResults)

Invalid column name 'Last Agent Communication'.
Invalid column name 'Last Configuration Request'.
Invalid column name 'Last Basic Inventory Received'.
Invalid column name 'Communication Health'.
Invalid column name 'Configuration Health'.
Invalid column name 'Basic Inventory Health'.
Invalid column name 'Agent Version Health'.
   [System.Data.SqlClient.SqlException @ .Net SqlClient Data Provider]
   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.SqlDataReader.TryConsumeMetaData()
   at System.Data.SqlClient.SqlDataReader.get_MetaData()
   at System.Data.SqlClient.SqlCommand.FinishExecuteReader(SqlDataReader ds, RunBehavior runBehavior, String resetOptionsString, Boolean isInternal, Boolean forDescribeParameterEncryption, Boolean shouldCacheForAlwaysEncrypted)
   at System.Data.SqlClient.SqlCommand.RunExecuteReaderTds(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, Boolean async, Int32 timeout, Task& task, Boolean asyncWrite, Boolean inRetry, SqlDataReader ds, Boolean describeParameterEncryptionRequest)
   at System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method, TaskCompletionSource`1 completion, Int32 timeout, Task& task, Boolean& usedCache, Boolean asyncWrite, Boolean inRetry)
   at System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method)
   at System.Data.SqlClient.SqlCommand.ExecuteReader(CommandBehavior behavior, String method)
   at System.Data.Common.DbDataAdapter.FillSchemaInternal(DataSet dataset, DataTable datatable, SchemaType schemaType, IDbCommand command, String srcTable, CommandBehavior behavior)
   at System.Data.Common.DbDataAdapter.FillSchema(DataSet dataSet, SchemaType schemaType, IDbCommand command, String srcTable, CommandBehavior behavior)
   at System.Data.Common.DbDataAdapter.FillSchema(DataSet dataSet, SchemaType schemaType)
   at Altiris.NS.DataAccessLayer.DatabaseAbilities.ExecuteSchemaSet(IDatabaseContext ctx, SchemaType t, String sql, Object[] parampairs)
   at Altiris.Reporting.DataSource.RawSqlDataSource.RunSchema()

SQL Exception details: code=207, line=8

Exception logged from: 
   at Altiris.NS.MvcWeb.Models.DataSourceWrapper.Run(Boolean, String&, System.Data.DataTable&)
   at Altiris.NS.MvcWeb.Controllers.Api.DataSourceApiController.Validate(Altiris.NS.MvcWeb.Models.DataSourceWrapper)
   at Altiris.NS.MvcWeb.Controllers.Api.ReportApiController.Save(Altiris.NS.MvcWeb.Models.ReportWrapper)
   at .lambda_method(System.Runtime.CompilerServices.Closure, Object, Object[])
   at System.Web.Http.Controllers.ReflectedHttpActionDescriptor+ActionExecutor+<>c__DisplayClass6_1.<GetExecutor>b__3(Object, Object[])
   at System.Web.Http.Controllers.ReflectedHttpActionDescriptor.ExecuteAsync(System.Web.Http.Controllers.HttpControllerContext, System.Collections.Generic.IDictionary<String,Object>, System.Threading.CancellationToken)
   at System.Web.Http.Controllers.ApiControllerActionInvoker+<InvokeActionAsyncCore>d__1.MoveNext()
   at System.Runtime.CompilerServices.AsyncTaskMethodBuilder<TResult>.Start<TStateMachine>(TStateMachine&)
   at System.Web.Http.Controllers.ApiControllerActionInvoker.InvokeActionAsyncCore(System.Web.Http.Controllers.HttpActionContext, System.Threading.CancellationToken)
   at System.Web.Http.Controllers.ApiControllerActionInvoker.InvokeActionAsync(System.Web.Http.Controllers.HttpActionContext, System.Threading.CancellationToken)
   at System.Web.Http.Controllers.ActionFilterResult+<ExecuteAsync>d__5.MoveNext()
   at System.Runtime.CompilerServices.AsyncTaskMethodBuilder<TResult>.Start<TStateMachine>(TStateMachine&)
   at System.Web.Http.Controllers.ActionFilterResult.ExecuteAsync(System.Threading.CancellationToken)
   at System.Web.Http.ApiController.ExecuteAsync(System.Web.Http.Controllers.HttpControllerContext, System.Threading.CancellationToken)
   at System.Web.Http.Dispatcher.HttpControllerDispatcher+<SendAsync>d__15.MoveNext()
   at System.Runtime.CompilerServices.AsyncTaskMethodBuilder<TResult>.Start<TStateMachine>(TStateMachine&)
   at System.Web.Http.Dispatcher.HttpControllerDispatcher.SendAsync(System.Net.Http.HttpRequestMessage, System.Threading.CancellationToken)
   at System.Net.Http.HttpMessageInvoker.SendAsync(System.Net.Http.HttpRequestMessage, System.Threading.CancellationToken)
   at System.Web.Http.Dispatcher.HttpRoutingDispatcher.SendAsync(System.Net.Http.HttpRequestMessage, System.Threading.CancellationToken)
   at System.Net.Http.DelegatingHandler.SendAsync(System.Net.Http.HttpRequestMessage, System.Threading.CancellationToken)
   at System.Web.Http.HttpServer+<SendAsync>d__24.MoveNext()
   at System.Runtime.CompilerServices.AsyncTaskMethodBuilder<TResult>.Start<TStateMachine>(TStateMachine&)
   at System.Web.Http.HttpServer.SendAsync(System.Net.Http.HttpRequestMessage, System.Threading.CancellationToken)
   at System.Net.Http.HttpMessageInvoker.SendAsync(System.Net.Http.HttpRequestMessage, System.Threading.CancellationToken)
   at System.Web.Http.WebHost.HttpControllerHandler+<ProcessRequestAsyncCore>d__12.MoveNext()
   at System.Runtime.CompilerServices.AsyncTaskMethodBuilder.Start<TStateMachine>(TStateMachine&)
   at System.Web.Http.WebHost.HttpControllerHandler.ProcessRequestAsyncCore(System.Web.HttpContextBase)
   at System.Web.TaskAsyncHelper.BeginTask(System.Func<System.Threading.Tasks.Task>, AsyncCallback, Object)
   at System.Web.HttpApplication+CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute()
   at System.Web.HttpApplication.ExecuteStepImpl(System.Web.HttpApplication+IExecutionStep)
   at System.Web.HttpApplication.ExecuteStep(System.Web.HttpApplication+IExecutionStep, Boolean&)
   at System.Web.HttpApplication+PipelineStepManager.ResumeSteps(Exception)
   at System.Web.HttpApplication.BeginProcessRequestNotification(System.Web.HttpContext, AsyncCallback)
   at System.Web.HttpRuntime.ProcessRequestNotificationPrivate(System.Web.Hosting.IIS7WorkerRequest, System.Web.HttpContext)
   at System.Web.Hosting.PipelineRuntime.ProcessRequestNotificationHelper(IntPtr, IntPtr, IntPtr, Int32)
   at System.Web.Hosting.PipelineRuntime.ProcessRequestNotification(IntPtr, IntPtr, IntPtr, Int32)
   at System.Web.Hosting.UnsafeIISMethods.MgdIndicateCompletion(IntPtr, System.Web.RequestNotificationStatus&)
   at System.Web.Hosting.UnsafeIISMethods.MgdIndicateCompletion(IntPtr, System.Web.RequestNotificationStatus&)
   at System.Web.Hosting.PipelineRuntime.ProcessRequestNotificationHelper(IntPtr, IntPtr, IntPtr, Int32)
   at System.Web.Hosting.PipelineRuntime.ProcessRequestNotification(IntPtr, IntPtr, IntPtr, Int32)

User [SCSS\adm.altiris], Auth [SCSS\Adm.Altiris], AppDomain [/LM/W3SVC/1/ROOT/Altiris/MvcWeb-10-132690217278123310]

HTTP [POST]: https://scss-itms.local/Altiris/MvcWeb/reportapi/Save
 ip: [192.168.20.20]; languages: [en-GB,en;q=0.9,en-US;q=0.8]; content-length: [2756];
 timings: [[R] 00:00:00.0309334(W: 00:00:00)];
 response: [200 OK]; x-smp-nsversion: [8.6.1119.0];

-----------------------------------------------------------------------------------------------------
Date: 2021/06/25 09:19:12, Tick Count: 600262875 (6.22:44:22.8750000), Host Name: SCSS-ITMS, Size: 8,10 KB
Process: w3wp (11108), Thread ID: 214, Module: Altiris.NS.MvcWeb.dll
Priority: 1, Source: Altiris.NS.MvcWeb.Models.DataSourceWrapper.Run
File: C:\ProgramData\Symantec\SMP\Logs\a.log
​
Rufus Swart's profile image
Rufus Swart
It seems to be with the copy and past from SSMS to WEB page
Rufus Swart's profile image
Rufus Swart
turns out to be copying from VM to MacOS on MS Edge for Mac that is doing some stupid thing... when copied from the same VM and accessing the console directly on the vm is works.