question

pwl2706 avatar image
pwl2706 asked

T-SQL - replace substring using wildcards

Hi, |I have several hundred SQL queries that need to be modified by removing a certain part of the WHERE Clause I want to remove this string: `AND CHARINDEX([DL_LiquidityBandMat],'%;')>0` where % could be A3, A4, A5, AA, AB etc what's the best way to do that please? It's a one off task thanks for any help Philip
t-sqldelimited-stringstring-splitting
10 |1200 characters needed characters left characters exceeded

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

1 Answer

· Write an Answer
sqlaj 1 avatar image
sqlaj 1 answered
Hopefully you have all the queries already in source control or somewhere outside of the database. If not you will need to do that first. After that you have several options. - SQL Server Management Studio, open the files and Search/Replace. - Powershell script to look at all the files in a directory and replace the string characters. - Third Party Software to search and replace. Any way you go there is going to be some work involved.
1 comment
10 |1200 characters needed characters left characters exceeded

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

One off or not, I'd go the route of automating it using PowerShell.
0 Likes 0 ·

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.