Click here to Skip to main content
15,880,967 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
I want remove first zero in areacode column..

areacode areaname

A000001 bangalore
A000002 delhi
A000003 mumbai
A000004 kolkata
A000005 Hyderbad

result should be like this
A00001 bangalore
A00002 delhi
A00003 mumbai
A00004 kolkata
A00005 Hyderbad

How to do this pls tell me
Posted

1 solution

Try:
SQL
SELECT SUBSTRING(areacode, 1, 1) + SUBSTRING(areacode, 3, 1000) AS Areacode, areaname FROM MyTable


"I want to update that column .not only select"

So tell us exactly what you want!
It's a trivial mod anyway:
SQL
UPDATE MyTable SET areacode = SUBSTRING(areacode, 1, 1) + SUBSTRING(areacode, 3, 1000)

But backup first incase you make a mistake: always backup before you run an UPDATE without a WHERE clause!
 
Share this answer
 
v2
Comments
Member 11337367 28-Feb-15 3:50am    
I want to update that column .not only select
OriginalGriff 28-Feb-15 4:01am    
Answer updated
Member 11337367 28-Feb-15 4:10am    
Could you tell me how this query will works..what sub string command will l do..
OriginalGriff 28-Feb-15 5:58am    
Um...did you look at the updated answer?
Member 11337367 28-Feb-15 6:04am    
Ya.That is updated..

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