Re: Can't login to SQL Server
- From: Erland Sommarskog <esquel@xxxxxxxxxxxxx>
- Date: Sat, 26 Jan 2008 09:35:15 -0800
Klerman Gutierrez (mcs@xxxxxxxxxxxxxxxxxxxxxxxx) writes:
The SQL than I'm using is this:
exec sp_addlogin 'USERA', 'xxxxx', 'MyDatabase'
exec sp_addsrvrolemember 'USERA', sysadmin
exec sp_addlogin 'USERB', 'xxxxxx', 'MyDatabase'
EXEC sp_grantdbaccess 'USERB'
EXEC sp_addrolemember db_datareader, 'USERB'
EXEC sp_addrolemember db_datawriter, 'USERB'
Have you checked the output from this script? From your description I
would expect this command to fail:
EXEC sp_grantdbaccess 'USERB'
There is already a USERB in the database per your description. The
database user is part of the database, so it was included when you copied
the database.
What you need to do is to connect the existing database user USERB
with the newly created login USERB. (The logins are stored in master,
so the login USERB was not included in the copy operation.) You can
do this with the command:
ALTER USER USERB WITH LOGIN = USERB
If this gives you a syntax error, it is because you have not applied SP2
of SQL 2005, which you should do.
There is one more thing you need to be aware of: in SQL 2005, passwords
are always case-sensitive. So if the script says:
exec sp_addlogin 'USERB', 'TopSecret', 'MyDatabase'
and you try to log in with "topsecret" that will fail.
Finally, while the above commands work on SQL 2005, SQL 2005 now has
proper commands to create logins and user, CREATE LOGIN and CREATE USER.
There are no commands for adding users to roles though.
--
Erland Sommarskog, SQL Server MVP, esquel@xxxxxxxxxxxxx
Books Online for SQL Server 2005 at
http://www.microsoft.com/technet/prodtechnol/sql/2005/downloads/books.mspx
Books Online for SQL Server 2000 at
http://www.microsoft.com/sql/prodinfo/previousversions/books.mspx
.
- Follow-Ups:
- Re: Can't login to SQL Server
- From: Klerman Gutierrez
- Re: Can't login to SQL Server
- References:
- Can't login to SQL Server
- From: Klerman Gutierrez
- Re: Can't login to SQL Server
- From: Erland Sommarskog
- Re: Can't login to SQL Server
- From: Klerman Gutierrez
- Can't login to SQL Server
- Prev by Date: Re: Can't login to SQL Server
- Next by Date: Re: Can't login to SQL Server
- Previous by thread: Re: Can't login to SQL Server
- Next by thread: Re: Can't login to SQL Server
- Index(es):
Relevant Pages
|