Click here to Skip to main content
15,890,670 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
Hi all,
i have the data like this
name
south America
north America
East America
west America


required output is
name
south
north
East
west


Thanks & Regards,
prakash.ch
Posted
Updated 16-Sep-13 7:00am
v2
Comments
[no name] 16-Sep-13 10:25am    
And? Did you maybe forget a question? Or maybe you had some sort of a problem with the code that you have written?
prakash.chakrala 16-Sep-13 10:28am    
In name column i have the data like south america(and mentioned above) so my requirement is to
get output as south(and mentioned above)
[no name] 16-Sep-13 10:49am    
Okay and so? What is your question or what is the problem? Did you actually try anything or do you expect us to do all of your work for you?
phil.o 16-Sep-13 10:30am    
Nice requirement! Good luck!
Thanks7872 16-Sep-13 12:32pm    
And so many members here on CP feels this as question... :-)

Have a look at the REPLACE function
* Clicky *

SQL
SELECT REPLACE(NAME, ' America', '') AS [NAME] FROM tblAmericas;
 
Share this answer
 
v2
Comments
Maciej Los 16-Sep-13 13:01pm    
Well done!
+5!
Hi,

Check the below code...

SQL
CREATE TABLE #Test (Name VARCHAR(100))

INSERT INTO #Test (Name)
SELECT 'south America'
UNION ALL SELECT 'north America'
UNION ALL SELECT 'East America'
UNION ALL SELECT 'west America'

SELECT Name , SUBSTRING(Name, 1, CHARINDEX(' ', Name,1))
FROM #Test

DROP TABLE #Test

Regards,
GVPrabu
 
Share this answer
 
Comments
Maciej Los 16-Sep-13 13:00pm    
Good work!
+5!

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900