Create a new db user in SQL Server 2005

前端 未结 6 980
轮回少年
轮回少年 2021-01-02 14:06

how do you create a new database user with password in sql server 2005?

i will need this user/password to use in the connection string eg:

uid=*user*         


        
6条回答
  •  灰色年华
    2021-01-02 14:51

    As of SQL Server 2005, you should basically create users in two steps:

    • create a "login" to your SQL Server as a whole
    • create users for this login in each database needed

    You'd go about doing this like so:

    CREATE LOGIN MyNewUser WITH PASSWORD = 'top$secret';
    

    And the "USE" your database and create a user for that login:

    USE AdventureWorks;
    CREATE USER MyNewUser FOR LOGIN MyNewUser
    

提交回复
热议问题