I am writing a stored proc to
1) Create a new user
2) Give that user access to several databases and
3) Setup a user role in all the databases.
It seems to work fine, however, I get the following error when I click the Database Access tab for the user in Enterprise Manager:
The name was not found in the users collection. If the name is a qualified name, then use []to separate various parts of the name, and try again
Here is part of my code in the stored procedure:
--Setup a new login for the user if it does not exist
if not exists (select * from master..syslogins where name = @login)
BEGIN
exec sp_addlogin @login, @pwrd
END
--Change the default database for the user
exec sp_defaultdb @login, 'members'
--Grant DB access to the user
exec sp_grantdbaccess @login, @pwd OUT
--Add the role
exec sp_addrolemember @role, @login
Does anyone have any ideas why I get that error in EM? Your help is very much appreciated!
Thanks,
Steve S
sms@hmbnet.com
1) Create a new user
2) Give that user access to several databases and
3) Setup a user role in all the databases.
It seems to work fine, however, I get the following error when I click the Database Access tab for the user in Enterprise Manager:
The name was not found in the users collection. If the name is a qualified name, then use []to separate various parts of the name, and try again
Here is part of my code in the stored procedure:
--Setup a new login for the user if it does not exist
if not exists (select * from master..syslogins where name = @login)
BEGIN
exec sp_addlogin @login, @pwrd
END
--Change the default database for the user
exec sp_defaultdb @login, 'members'
--Grant DB access to the user
exec sp_grantdbaccess @login, @pwd OUT
--Add the role
exec sp_addrolemember @role, @login
Does anyone have any ideas why I get that error in EM? Your help is very much appreciated!
Thanks,
Steve S
sms@hmbnet.com