• Hugo Kornelis (2/13/2016)


    curious_sqldba (2/12/2016)


    I have a script which basically scripts out all the users along with permissions needed, my script will spit a script that should be executed to grant permissions. My problem is i have quite a few logins that i need to find/replace in the script, is there a good way to find/replace text? This might more generic question, i am thinking power shell could do it but never tried.

    Copy the script in an SSMS query window and hit Ctrl-H?

    Or save it, load it in your favorite text editor?

    Depending on what you exactly need, it might also be possible to change the query that produces the script.

    I have a table something like this:

    CurrentLoginName UpdatedLoginName

    domain1\John domain2\John

    I want an automated way which will basically loop through a table and replace whereever domain1\john is with domain2\john, i have 100+ logins to be replaced. Modifying the existing code to do replace is tedious, so basically script should take a .sql file,loop through the table and replace the values and create a new script with updated values.