September 19, 2011 at 7:14 am
I have a table with data like this example:
Pedro
Pedro Martins
Maria
Maria Ana Marta
Monica
Monica2
Monica1
Monica azenha
I what that the query selects only names that have a space. If the name is a single word i want that it be excluded from the results.
Can some one help?
Thanks.
P.S - Example of the query result desired
Pedro Martins
Maria Ana Marta
Monica azenha
September 19, 2011 at 7:20 am
WHERE CHARINDEX(' ',ColumnName) > 0 is one way.
WHERE ColumnName LIKE '% %' is another;
you can also count the number of spaces and use that as criteria:
WHERE DATALENGTH(ColumnName ) - DATALENGTH(REPLACE(ColumnName,' ','') > 0
Lowell
September 19, 2011 at 7:37 am
WHERE ColumnName LIKE '% %' is another;
Thank you
September 19, 2011 at 7:46 am
what about numbers?
I don't want that names having number appear in the query results pan.
i.e - Pedro2
Pedro
Only want Pedro
September 19, 2011 at 7:59 am
WHERE ColumnName NOT LIKE '%[0-9]%'
Viewing 5 posts - 1 through 4 (of 4 total)
You must be logged in to reply to this topic. Login to reply