Add another db to a login

  • Hi,

    I need to create a login that refers to 2 databases, but I have to use a script. I use

    "EXEC sp_addlogin 'Cris' , 'Cris', 'MyDB', 'us_english'"

    So, I want this login to point also to 'HisDB'.

    How can I do this with T-SQL?

    Thanks

  • You can use sp_grantdbaccess procedure.

    1) Login as sa or dbo

    2) USE HisDB

    3) EXEC sp_grantdbaccess 'Cris', 'Cris'

    Thanks

    Regards

    Ram

    ram@cntit.com

  • SP_grantdbaccess is the preferred method. If you look at sp_addlogin it just in turn calls sp_grantdbaccess.

    Andy

  • Thank you for your answers. I solved my problem with sp_grantdbaccess.

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

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