
I’m writing a query to get fname from user_name_n column in following query I’m using pathindex to find space as '% %' passing that pathindex return value to left
and it works fine but I’ve records with , also how can i write a query
that will also take care of ,.
and some records like Bellian doesn’t have space or , but still i want them in fname
but it’s not working with following query.
SELECT top 100 user_name_n,left(user_name_n,(patindex('% %',user_name_n)))
from SFCHA10_04_02_2012;
can anyone tell me how can i achieve the desired results.
Note that you can use ‘%[, ]%’ to search for a space or a comma. Also note that I added a + ‘ ‘ to the second parameter. This causes there to be a match even when the data does not contain a space.