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.
Author |
Topic |
peace
Constraint Violating Yak Guru
420 Posts |
Posted - 2014-01-21 : 21:05:06
|
i have value with data type nvarchar:total000000854.00000000042.00000000065.17000000000024000000000.24how can i convert to decimal and remove 0 infront? but those with 0.xx would not remove the 0 after the dote.total854.0042.0065.17240.24 |
|
khtan
In (Som, Ni, Yak)
17689 Posts |
Posted - 2014-01-21 : 21:10:57
|
[code]convert( decimal(10,2) , total )[/code]quote: how can i convert to decimal and remove 0 infront? but those with 0.xx would not remove the 0 after the dote.
you don't need to worry about that if it is decimal KH[spoiler]Time is always against us[/spoiler] |
 |
|
peace
Constraint Violating Yak Guru
420 Posts |
Posted - 2014-01-21 : 21:23:41
|
quote: Originally posted by khtan
convert( decimal(10,2) , total ) quote: how can i convert to decimal and remove 0 infront? but those with 0.xx would not remove the 0 after the dote.
you don't need to worry about that if it is decimal KH[spoiler]Time is always against us[/spoiler]
im still getting the same output. |
 |
|
khtan
In (Som, Ni, Yak)
17689 Posts |
Posted - 2014-01-21 : 21:44:30
|
show your query KH[spoiler]Time is always against us[/spoiler] |
 |
|
peace
Constraint Violating Yak Guru
420 Posts |
Posted - 2014-01-21 : 21:52:03
|
what i meant is the data originally as nvarchar(50)total000000854.00000000042.00000000065.17000000000024000000000.24....i wanted to convert into decimal and remove the 0 infront to be like this:total854.0042.0065.17240.24....is it possible? |
 |
|
khtan
In (Som, Ni, Yak)
17689 Posts |
Posted - 2014-01-21 : 22:32:22
|
update back to the table ?update yourtableset total = convert(varchar(10), convert( decimal(10,2) , total ) ) KH[spoiler]Time is always against us[/spoiler] |
 |
|
peace
Constraint Violating Yak Guru
420 Posts |
Posted - 2014-01-21 : 23:05:00
|
working fine.Thanks |
 |
|
|
|
|
|
|