Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2005 Forums
 Transact-SQL (2005)
 How to replace part of numeric value

Author  Topic 

reddy_vam
Starting Member

43 Posts

Posted - 2009-10-16 : 00:35:32
I have table with having numeric values in a column like shown below.

ID
---
1234
124546
1265757
12090989

I want to replace first 2 numeric values with another number, so that output will be like

ID
---
5634
564546
5665757
56090989

Somebody help me with the command please?

Thanks,
Vamshi

dinakar
Master Smack Fu Yak Hacker

2507 Posts

Posted - 2009-10-16 : 00:47:11
Try using one of the LEFT or RIGHT functions... perhaps in combination with LEN.

Dinakar Nethi
************************
Life is short. Enjoy it.
************************
http://weblogs.sqlteam.com/dinakar/
Go to Top of Page

webfred
Master Smack Fu Yak Hacker

8781 Posts

Posted - 2009-10-16 : 01:04:39
The first question is what data type is the column ID?
The second question is if there is a condition to change the value or not?
The third question is if there are related records in other tables to this IDs?


No, you're never too old to Yak'n'Roll if you're too young to die.
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2009-10-16 : 04:12:12
select col, stuff(col,1,2,'56') from your_table

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page
   

- Advertisement -