Click here to Skip to main content
12,395,143 members (60,950 online)
Rate this:
 
Please Sign up or sign in to vote.
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
 
good
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!
  Permalink  
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
E.F. Nijboer 18-Feb-13 12:54pm
   
Not clear to me. Can you elaborate?
itsureshuk 20-Feb-13 0:25am
   
You Can pass Columnname in Substring(Columnname,Start,Length)
E.F. Nijboer 20-Feb-13 2:56am
   
Haven't you tried?
E.F. Nijboer 18-Feb-13 6:52am
   
By the way, have a look here:
http://msdn.microsoft.com/en-us/library/ms187748.aspx

http://msdn.microsoft.com/en-us/library/ms187928.aspx

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

  Print Answers RSS
Top Experts
Last 24hrsThis month


Advertise | Privacy | Mobile
Web02 | 2.8.160721.1 | Last Updated 18 Feb 2013
Copyright © CodeProject, 1999-2016
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