Friday, February 16, 2018

Sql query to Split column value with / and display only left hand side

 




 


SELECT   Rtrim(Ltrim(case when (LongAddress is NULL or LongAddress='') then '' else substring(LongAddress, 1,CASE WHEN CHARINDEX('/',LongAddress) - 1 < 0  THEN LEN(LongAddress)
                      ELSE CHARINDEX('/',LongAddress) - 1 END) end)) as LongAddress,LongAddress from sampletable


No comments:

Post a Comment