I hope this tip can help you, but I look forward to your comments on improving the solution! I could have regenerated the scripts, but I no longer had access to the source database server, so I had to deal with with I had available. Then, I also opted to have SSMS save the files in Unicode because, well, why not? Turns out the Windows command interpreter’s FOR /F doesn’t support UTF-8. I had created SQL scripts from a database, but SSMS had helpfully added a descriptive line and then a few unwanted SET statements, like so: /*** COMMENTS ***/ I had 697 files to process and Notepad did that in under 2 minutes. Here is how I set up the Find in Files in Notepad (version 7.1): How I set up Notepad to remove the first 5 lines from all. I left Replace with blank and set the Filters to *.sql. I placed that regex in the Find what box in Notepad Find in Files dialog. Finding the right regex was not too hard: (.*(\R))). It has a Find in Files option that supports regex. I settled on using Notepad , my go-to text editor. There probably are better solutions available. Note: the solution here is the one I settled on because it’s the first one that worked for me. This seems simple enough… but I had to try a few methods to get it right.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. Archives
December 2022
Categories |