Quantcast
Channel: Questions in topic: "best-practice"
Viewing all articles
Browse latest Browse all 45

Format Data using CHARINDEX or PATINDEX

$
0
0
How to use CHARINDEX or PATINDEX to format the data Separately.

Eg. Declare @a Varchar(100) 
SET @a= 'CityName,StateName,CountryName'
SELECT STUFF(@a,PATINDEX('%,%',@a),LEN(@a),'')
Result: 'CityName'

But I need the result as  
'CityName' 
'StateName'
'CountryName'

Please advice to fetch the data like above....

Viewing all articles
Browse latest Browse all 45

Trending Articles