Site Sponsored By: SQLDSC - SQL Server Desired State Configuration
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.
Hi,i have a column which has values like,012340044500067....i want to update those column like,123444567how can i do it?
harsh_athalye
Master Smack Fu Yak Hacker
5581 Posts
Posted - 2007-04-16 : 10:06:24
[code]-- sample datadeclare @t table( a varchar(10))insert @t select '01234' union allselect '00445' union allselect '00067' -- final queryupdate @tset a = convert(varchar(10), cast(a as int))select * from @t[/code]Harsh AthalyeIndia."The IMPOSSIBLE is often UNTRIED"
harsh_athalye
Master Smack Fu Yak Hacker
5581 Posts
Posted - 2007-04-16 : 10:09:15
Another solution:
-- sample datadeclare @t table( a varchar(10))insert @t select '01234' union allselect '00445' union allselect '00067' union allselect '002707' union allselect '0460'-- final queryupdate @tset a = replace(ltrim(replace(a, '0', ' ')), ' ', '0')select * from @t
Harsh AthalyeIndia."The IMPOSSIBLE is often UNTRIED"
madhivanan
Premature Yak Congratulator
22864 Posts
Posted - 2007-04-16 : 10:15:39
You shouldnt have used varchar to store numbersIf you want to show formatted data in front end, use format function thereMadhivananFailing to plan is Planning to fail