i have asked to perfrom a task to create a New login & then provide the access rights to a particular DB..
I did it with no time :-)
After this i am asked to create 50 New Login's & give them DB access privilages to each of them..
The total Databses are 150
Please help me with a query where in i can perform this activity easily :-(
Well, in general, you create multiple roles, each containing the permissions you want to give, and then you create users, to match the logins, in each database, and assign them to the appropriate roles.
In your case, you didn't give any information about the details, so we cannot help much with that.
are the permissions going to be exactly the same for all 150 databases? does every login have access to all 150 databases?
when you define that, we could offer scripts that use things like sys.databases to generate a script for each database;
something like this:
CREATE ROLE [AlmostOwners]
EXEC sp_addrolemember N''''db_ddladmin'''', N''''AlmostOwners''''
EXEC sp_addrolemember N''''db_datareader'''', N''''AlmostOwners''''
EXEC sp_addrolemember N''''db_datawriter'''', N''''AlmostOwners''''
--can the users EXECUTE procedures? comment out if false
GRANT EXECUTE TO [AlmostOwners]
--allow the users to see view proc and function definitions
Grant View Definition ON SCHEMA::[dbo] To [AlmostOwners]
help us help you! If you post a question, make sure you include a CREATE TABLE... statement and INSERT INTO... statement into that table to give the volunteers here representative data. with your description of the problem, we can provide a tested, verifiable solution to your question! asking the question the right way gets you a tested answer the fastest way possible!