TSQL - Regular Expression Example : Tsql Filter data based on Certain Pattern

i will let you how to use Regular Expression in Tsql using one example /

we need to filter the data of varchar column ,  value should be like DSx_HD_WSxx  example  DS1_HD_WS01_blablabla .
for this we can achieve by using 'DS__HD_WS__%'  but the problem is, we can also get DS10 or DS1000 .
In this case what pattern we need to use to accept any number after DS  then remaining as per previous patern.

we can achieve solution with the fallowing expression


'DS%[_]HD_WS%[_]%'



For single character we need to use  underscore _  and for many chacters we need to use %

Comments

Popular posts from this blog

SSAS : A connection cannot be made to redirector. Ensure that 'SQL Browser' service is running. (Microsoft.AnalysisServices.AdomdClient). + Solution

SSIS Error : Unable to infer the XSD from the XML file. The XML contains multiple namespaces