How to use SQLCMD.exe in Windows authentication no-trust cross domain scenario

  • I have a somewhat complex deployment scenario to deal with. I have two domains, production and test, which have no trust with one another. I'm implementing automated deployments from the production domain to the test domain, and the databases in the test domain use windows authorization only.

    We use sqlcmd.exe to deploy the actual scripts. We've attempted to use Invoke-SqlCmd, but it's not suitable for use in its current state, and we're not considering it any longer.

    Sqlcmd: Error: Microsoft ODBC Driver for 13 SQL SERVER : Login failed for user 'Domain name\Servername$'.

    We have mulitple instances of SQL SERVER running in test domain. How to resolve this error.

  • Have you tried anything like RunAs?  RunAs is a commandline tool that allows you to run a process as a different user.  I am not sure if you would be able to access anything locally with a login from a different domain, but it is worth a shot.

  • RunAs will not work.  

    You will be using it in the production domain, and trying to connect as a test domain user. There is no visibility between the domains, the authentication will fail. 

    This may work.
    1. Create a local account on each machine, same user name and password.  Make sure that account is granted the proper rights in SQL. 
    2. Use open a command prompt, use "Run as different user", and use the newly created account.  Do not enter the user name as MachineName\login, enter it as .\Login.
    3. Run the SQLCMD in the command prompt.

    Michael L John
    If you assassinate a DBA, would you pull a trigger?
    To properly post on a forum:
    http://www.sqlservercentral.com/articles/61537/

Viewing 3 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic. Login to reply