SQL Server error assigning windows user to database

moondaddy 911 Reputation points
2021-10-30T20:11:14.393+00:00

Using sql server 2019 I have a windows user and want to assign it to a database. but no mater which which windows user I use, I get an error

Create failed for User 'xxx-xxx\sysadmin'.
'xxx-xxx\sysadmin' is not a valid name because it contains invalid characters.

Where "xxx-xxx" is the machine name created by the datacenter.

It seems odd that I can't assign a windows user to the db. Any solutions?

Thanks.

SQL Server
SQL Server
A family of Microsoft relational database management and analysis systems for e-commerce, line-of-business, and data warehousing solutions.
12,691 questions
{count} votes

Accepted answer
  1. Erland Sommarskog 100.9K Reputation points MVP
    2021-10-30T21:16:47.263+00:00

    Microsoft SQL Server 2019 (RTM-GDR) (KB4583458) - 15.0.2080.9 (X64) Nov 6 2020 16:50:01 Copyright (C) 2019 Microsoft Corporation Developer Edition (64-bit) on Windows Server 2019 Datacenter 10.0 <X64> (Build 17763: ) (Hypervisor)

    While unlikely to be related to this problem, you should apply the most recent Cumulative Update which is CU13 to get access to many bug fixes in SQL 2019.

    Using SSMS, not scripts, database/security/users, select "New User". User type = Windows user, Select a windows user "machinename\username, Login name = username, default schema = dbo, click OK

    I tried this and it worked for me with SSMS 18.10. Which version of SSMS do you have? Did you try the Script button to see what SSMS actually generates? It would help to see a screenshot.


1 additional answer

Sort by: Most helpful
  1. Erland Sommarskog 100.9K Reputation points MVP
    2021-10-30T20:48:47.593+00:00

    It would have helped if you had shown us the actual command you are using.

    This command is from a demo script that I have:

    CREATE USER [LIVERPOOL\SirPaul]
    

    and that I know runs if I change LIVERPOOL to my actual machine name.

    Also, post the output from SELECT @@version.

    0 comments No comments