Consider this TSQL:
declare @b varchar(100)
set @b = 'BANK-41'
IF @b LIKE 'BANK_%'
BEGIN
print 'Wrong Matching'
END
Why does the TSQL match the string "BANK-" and "BANK_"?
In TSQL the underscore is a wildcard representing a single char.
In order to escape in you need to wrap it with square brackets, like this:
'BANK[_]%'
See this page: http://www.dirigodev.com/blog/web-development-execution/escaping-percent-and-underscore-characters-in-t-sql-like-clause/
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With