A map service published from a query layer fails to display and query when the database connection is registered over OS (operating system) authentication.
Remove the database name from the query string in ArcMap.1. Add the query layer to the MXD.2. Right-click the query layer in the Table Of Contents > Properties.3. In the Source tab, click 'Change Query'.4. By default, the query is displayed as the following:select OBJECTID, NAME, Shape from geodatabase.dbo.Buildings5. Change the query to remove the database name:select OBJECTID, NAME, Shape from dbo.BuildingsAfter publishing the service, the data displays or queries as expected.