Script SQL Server login with Windows authentication without machine name

Posted by Evgeny on Stack Overflow See other posts from Stack Overflow or by Evgeny
Published on 2009-02-12T04:18:50Z Indexed on 2010/04/28 23:07 UTC
Read the original article Hit count: 234

Filed under:
|

I want to write a SQL 2005 script to create a new login that uses Windows authentication. The Windows user is a local account (not a domain one). A local account with the same name exists on many SQL Server machines and I want to run the same script on all of them.

It seemed simple enough:

CREATE LOGIN [MyUser]
FROM WINDOWS

However, that doesn't work! SQL returns an error, saying Give the complete name: <domain\username>.

Of course, I can do that for one machine and it works, but the same script will not work on other machines.

© Stack Overflow or respective owner

Related posts about sql-server

Related posts about DBA