April 9, 2007 at 2:35 pm
I do not mean to grant it using GUI.
I mean how to do it using script?
Any input is greatly appreciated.
April 9, 2007 at 2:39 pm
Make sure you create the associated user in the database first from the login and then you can do something like:
exec sp_addrolemember 'db_datareader', 'someuser'
April 10, 2007 at 7:05 am
for sql login that sets the password and the corpdatabase as default database
EXEC sp_addlogin 'testuser', 'password', 'corpdatabase'
use corpdatabase
EXEC sp_addrolemember 'db_datareader','testuser'
Your first place to search for an answer is SQL BOL. Make sure it is installed.
Good day...
Bulent
April 23, 2007 at 12:58 pm
One step was possibly missing and some refinements:
use master
go
exec sp_addlogin @loginame='THE_LOGINAME', @passwd='A_very_Secure_Password', @defdb='THE_DATABASE_NAME'
exec THE_DATABASE_NAME..sp_adduser @loginame='THE_LOGINAME'
exec THE_DATABASE_NAME..sp_addrolemember @rolename='db_datareader', @membername='THE_LOGINAME'
go
checkpoint
go
RegardsRudy KomacsarSenior Database Administrator"Ave Caesar! - Morituri te salutamus."
Viewing 4 posts - 1 through 3 (of 3 total)
You must be logged in to reply to this topic. Login to reply