Where to create the login and user account

  • I need to create a login and a user account in several databases using t-sql

    I need to know where (in wich database) to create the login and the user account.

    If i have a login like:

    CREATE LOGIN test WITH PASSWORD='test'

    Do i have to create this having the query window in the master database? or can the query window be connected to other database (e.g a user database).

    What about the account:

    USER test FOR LOGIN test WITH Default_schema=dbo

    Should the query window of MS be connected to the master database or to the user database?

    Thank you

  • river1 (3/24/2010)


    I need to create a login and a user account in several databases using t-sql

    I need to know where (in wich database) to create the login and the user account.

    If i have a login like:

    CREATE LOGIN test WITH PASSWORD='test'

    Do i have to create this having the query window in the master database? or can the query window be connected to other database (e.g a user database).

    What about the account:

    USER test FOR LOGIN test WITH Default_schema=dbo

    Should the query window of MS be connected to the master database or to the user database?

    Thank you

    doesnt matter for the create login as they are always created in master anyway. For the Create user you need to specify a USE for the database you want the user created in

    -----------------------------------------------------------------------------------------------------------

    "Ya can't make an omelette without breaking just a few eggs" 😉

  • Thank you very much Perry

  • No problem, glad i could help!

    -----------------------------------------------------------------------------------------------------------

    "Ya can't make an omelette without breaking just a few eggs" 😉

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

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