Click here to Skip to main content
15,867,686 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
HTML
Hi Frnds,
 I Have Table like this 
                          ID    Name
                        123156    A
                        123157    B
                        123158    C
                        125123    D
                        125124    E

I need to Update this table as follows
                           ID    Name
                        124156    A
                        124157    B
                        124158    C
                        125123    D
                        125124    E

Here Rows 1,2,3 Contains start id with 123 ie 3,i have to replace with 124 ie 4.... Have to replace 3 as 4.
Posted

1 solution

Would be a very bad idea to update ID's, but if you really must you can use LIKE or SUBSTRING for that. you first need to convert the ID to text, process it, and convert it back.

Good luck!
 
Share this answer
 
Comments
itsureshuk 18-Feb-13 4:14am    
please give some queries example
E.F. Nijboer 18-Feb-13 5:01am    
Have you tried something yourself? Please add the query you got so far and what you have tried. I'm more than willing to help out but ain't going to do your work.
itsureshuk 18-Feb-13 5:46am    
update tbName
set ColName= substr(ColName,3,1) || ’4′
where substr(ColName,3,1)=’3′;
E.F. Nijboer 18-Feb-13 6:50am    
Did you try to execute this query? There is no SUBSTR in SQL2008. Also, how did you come up with ColName?
itsureshuk 18-Feb-13 10:23am    
sorry SUBSTRING only
substr is oracle,,,We can pass column values in substring r not

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