Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

security T-SQL

Status
Not open for further replies.

Bell1991

Programmer
Aug 20, 2003
386
US
I am trying to script my users and here is what i have:

use TestDB
EXEC SP_ADDLOGIN 'testUser', 'testPass', 'TestDB'
EXEC SP_GRANTDBACCESS 'testUser'
EXEC SP_ADDROLEMEMBER 'DB_DATAWRITER', 'testUser'

I don't get any errors - but when i go into Enterprise Manager and click Database Access and the Name of the Database to check to make sure the user has write access i get the following error:

The name 'testUser' was not found in the Users collection. If the name is a qualified name, user [] to sperate various parts of the name, and try again.

Any ideas on what i am doing wrong?

Thanks in advance,
-Bell
 
Is the account used to execute the script a member of sysadmin or securityadmin roles?
 
The script looks fine. I just ran it against one of my testdb's and it created the user and added it to db_datawriter as expected. What version of SQL are you running?
 
I figured it out..

I left one of the parameters off SP_GRANTDBACCESS

Thanks,
-Bell
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top