After migrating a SQL Server from a physical server to virtual server I had a job that stoped working. That job used sqlcmd.exe to run a simple SELECT out to a file on a network share for some other app to pickup and import. This job worked great for years but after the migration to a VM it started throwing this error:
“Sqlcmd: Error: Microsoft ODBC Driver 11 for SQL Server : Login failed. The login is from an untrusted domain and cannot be used with Windows authentication..”
Untrusted domain? I only have one domain… I was confused.
I won’t bore you with all the steps I took to troubleshoot, searching this error on the Googles will describe many varying solutions that may or may not work for you.
In my case, the problem was that my sqlcmd was using a DNS alias to connect to the SQL Server which also happened to be the local server. This same exception was also described in Microsoft’s KB957097. In fact, the Method 1 solution worked great to solve the problem.
However, I didn’t want a hidden list of acceptable local aliases lurking around in the registry that magically make some local jobs run. I opted to change my connection to use localhost for the server name and that worked as well.