Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 SQL Server Administration (2000)
 Add another db to a login

Author  Topic 

ttcrissy
Starting Member

8 Posts

Posted - 2002-03-25 : 02:44:02
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

nr
SQLTeam MVY

12543 Posts

Posted - 2002-03-25 : 06:49:07
The login just creates a connection to the server.
It has a defaut database in which it is working at that time. To have two default databases is meaningless.
You can change the database via a 'use dbname' command if you have permission or you can access objects in another database by using dbname.owner.tblname or better dbname.owner.spname

The login will need permission on the objects in the other database.

==========================================
Cursors are useful if you don't know sql.
Beer is not cold and it isn't fizzy.
Go to Top of Page
   

- Advertisement -