Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase

New login & Access to DB Expand / Collapse
Author
Message
Posted Tuesday, November 27, 2012 5:18 AM
SSC Veteran

SSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC Veteran

Group: General Forum Members
Last Login: Wednesday, March 12, 2014 12:13 AM
Points: 258, Visits: 690
Hi Friends,

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 :-(








************************************
Every Dog has a Tail !!!!!
Post #1389114
Posted Tuesday, November 27, 2012 5:52 AM


SSChampion

SSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampion

Group: General Forum Members
Last Login: Today @ 4:29 PM
Points: 12,741, Visits: 31,053
runal_jagtap (11/27/2012)
Hi Friends,

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:
EXEC sp_MSforeachdb 
'SELECT
''USE [?]
GO
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]
GO

'''



Lowell

--There is no spoon, and there's no default ORDER BY in sql server either.
Actually, Common Sense is so rare, it should be considered a Superpower. --my son
Post #1389133
Posted Thursday, November 29, 2012 1:08 AM
SSC Veteran

SSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC Veteran

Group: General Forum Members
Last Login: Wednesday, March 12, 2014 12:13 AM
Points: 258, Visits: 690
Thanks lowelll, willl try giving u complete proper info







************************************
Every Dog has a Tail !!!!!
Post #1390328
« Prev Topic | Next Topic »

Add to briefcase

Permissions Expand / Collapse