March 25, 2011 at 7:57 am
I resotre production database on dev on a regular basis and i have to give access to certian groups and people on those datasbase which i do manually, is there a way i can automate stuff like, create login,give read/write permissions on all the requried db's looping through each database.may be i can use cursor but can i do " use db;create login and so...."
March 25, 2011 at 11:32 am
Yes, you can use a cursor. This is one of my few universally acceptable uses of a cursor on SQL Server. You could also take a look at the undocumented procedure master.sys.sp_MSforeachdb.
There are no special teachers of virtue, because virtue is taught by the whole community.
--Plato
March 25, 2011 at 11:38 am
For such an action as you describe - cursors are somewhat commonplace. I would be careful about using msforeachdb though due to it's limitations (depends on the size of script you have to run for it). msforeachdb is essentially a cursor as well.
Jason...AKA CirqueDeSQLeil
_______________________________________________
I have given a name to my pain...MCM SQL Server, MVP
SQL RNNR
Posting Performance Based Questions - Gail Shaw[/url]
Learn Extended Events
Viewing 3 posts - 1 through 2 (of 2 total)
You must be logged in to reply to this topic. Login to reply