Hi
I want to sort a column value alphabetically which is already in a sql table to something like below :
Tamesha Rios, Damian Richard, Tim David --> to Damien Richard, Tamesha Rios, Tim David
Thanks,
PSB
I've created a test table and small static script which produces your desired output,
SELECT * INTO #TestTable FROM (VALUES
('Tamesha Rios,Damian Richard,Tim David')
)v(CSVField);
SELECT CSVField, PARSENAME(REPLACE(CSVField,',','.'),2) + ',' + PARSENAME(REPLACE(CSVField,',','.'),3) + ',' + PARSENAME(REPLACE(CSVField,',','.'),1) 'Name' FROM #TestTable
For realtime dynamic conversion, you'd need to create an user defined function which does the same. Please keep an eye on the performance of your function as well while executing....