I have a situation where the 6th and 7th character in a string need to equal '73'. I tried using LIKE '%73%'
but the problem is sometimes SQL Server will hit on other 73s that could be in the string. Is there a way to search only the 6th and 7th characters in the string?
Thank you all so much for the help!
Using like
, you can do:
where col like '_____73%'
Of course, the other solutions suggesting substring()
are also very sensible.
Use SUBSTRING ( expression ,start , length )
SELECT mycolumn
FROM mytable
WHERE SUBSTRING ( mycolumn ,6 , 2 ) = '73'
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