I am facing issue while using like operator with regex expression.
Below is the sample SQL script
create table #Temp (displayname varchar(100) )
insert into #Temp values('SG_UNFE_01_VIPCP30DY')
select * from #Temp where displayname like '%^[A-Z][A-Z]_[A-Z][A-Z]FE_[0-9][0-9]_VIP.*%'
drop table #Temp
Please help, Thanks in advance.
Answer by Kev Riley ·
You can't use REGEX syntax like that in T-SQL
What is it exactly the pattern you are trying to match?
The ^ denotes something to not match, so your first term after the % is saying match no characters A-Z. This on it's own will make the query return nothing as your example data does not fit.
The underscore _ matches a single character - if you want to match on it explicitly, then you have to escape it between square brackets 
The asterisk means nothing, so is trying to match exactly an asterisk
This query returns something
select * from #Temp where displayname like '%[A-Z][A-Z][_][A-Z][A-Z]FE[_][0-9][0-9][_]VIP%'
Answer by prathik ·
Thank you so much @Kev Riley. this what i was expecting. can you help me for OR case in below RegEx.