none
apply permissions automatically on databases using PS RRS feed

  • Question

  • Hi Team,

    I have dev environtment which consists of 100 databases. We used to take backup permissions of database users in share  and apply manually to new databases after refresh to ensure permissions are intact 

    permissions are saved for each database with time stamp. permission template  is below. Similarly there would be 100 files for 100 databases.

    Database Name--> Mango

    Permision file name-->Mango_20200728.sql

    After refresh below are the list of databases present in SQL Server

    1.Mango

    2.Mango_20200728

    3.Pineapple

    4.Pineapple_20200728

    And the files under the permission folder will be

    1.Mango_20200728.sql

    2.Pineapple_20200728.sql

    I want to go through databases which has time stamped in SQL Server and execute appropriate sql file from permission directory.

    Mango_20200728.sql has to be applied against Mango_20200728 database.

    Any suggestions

    Regards,

    ACDBA


    Best Regards,ACDBA

    Wednesday, July 29, 2020 6:05 PM

All replies

  • First, you need to ask SQL specific questions in the SQLServer forum.  

    Second, this is not a forum for asking others to write a script for you.  You need to learn about SQL and how to manage databases then apply what you have learned.  What you are asking is totally unnecessary if you are doing your DB backups correctly.  All of this is built into SQLServer and the SQL Server people will help you learn how to do this correctly.

    Third, this forum is for scripting and not for SQL which is not a system scripting language.

    See the following for more information.


    \_(ツ)_/

    Wednesday, July 29, 2020 7:14 PM
  • Thanks for replying.

    I am just looking for suggestions how to implement it. like kind of high level. logic wise. I guess such requests could be common.


    Best Regards,ACDBA

    Thursday, July 30, 2020 5:45 AM
  • This is not a SQL forum.  You need to post your requests in a SQL forum.


    \_(ツ)_/

    Thursday, July 30, 2020 5:50 AM
  • ACDBA, as I get you are interested in Get-ChildItem -File | Foreach { $_.name }

    Similar construction will iterate through all files and you can use File/Folder name in some actions like execution sql scripts

    But we do not know your task for 100% and all our suggestions may mean nothing (just guessing), so providing any ideas to you may provide you into the incorrect direction


    The opinion expressed by me is not an official position of Microsoft

    • Edited by Vector BCO Thursday, July 30, 2020 9:05 AM
    Thursday, July 30, 2020 8:19 AM