Click here to Skip to main content
11,644,286 members (69,260 online)
Rate this: bad
Please Sign up or sign in to vote.
See more: SQL-Server-2008
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 17-Feb-13 21:55pm

1 solution

Rate this: bad
Please Sign up or sign in to vote.

Solution 1

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!
itsureshuk at 18-Feb-13 4:14am
please give some queries example
E.F. Nijboer at 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 at 18-Feb-13 5:46am
update tbName
set ColName= substr(ColName,3,1) || ’4′
where substr(ColName,3,1)=’3′;
E.F. Nijboer at 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 at 18-Feb-13 10:23am
sorry SUBSTRING only
substr is oracle,,,We can pass column values in substring r not
E.F. Nijboer at 18-Feb-13 12:54pm
Not clear to me. Can you elaborate?
itsureshuk at 20-Feb-13 0:25am
You Can pass Columnname in Substring(Columnname,Start,Length)
E.F. Nijboer at 20-Feb-13 2:56am
Haven't you tried?
E.F. Nijboer at 18-Feb-13 6:52am
By the way, have a look here:

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

  Print Answers RSS
0 OriginalGriff 650
1 494
2 Afzaal Ahmad Zeeshan 423
3 Sergey Alexandrovich Kryukov 409
4 CPallini 352
0 OriginalGriff 925
1 DamithSL 636
2 Afzaal Ahmad Zeeshan 622
3 Sergey Alexandrovich Kryukov 548
4 CPallini 521

Advertise | Privacy | Mobile
Web01 | 2.8.150731.1 | Last Updated 18 Feb 2013
Copyright © CodeProject, 1999-2015
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100