creating a script to use sp_addrolemember

  • I swear I've seen a script out here somewhere that will create a script file so I can update each db with sp_addrolemember for ie: db_datawriter. But I've been looking for 3 days thru the site and can't find anything, I am crazy?

  • I'm not quite sure of your requirement, but here's code I would use:

     
    
    set quoted_identifier off
    exec sp_msForeachdb "
    use print '?'
    if '?' not in ('master','msdb')
    exec sp_addrolemember 'db_datawriter', 'Mark'
    "

    Cheers,

    - Mark


    Cheers,
    - Mark

Viewing 2 posts - 1 through 1 (of 1 total)

You must be logged in to reply to this topic. Login to reply