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 |
velliraj
Yak Posting Veteran
59 Posts |
Posted - 2010-08-06 : 05:54:42
|
Hi,I have the value which i was not able to convert into money due itsdata range is more than 8bytes.But i can able to convert into decimal, but i need in the money format like comma separated amountselect convert(varchar(100),convert(money,1235353536586647567.00),1)select convert(varchar(100),convert(decimal32,2),1235353536586647567.00),1) |
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2010-08-06 : 06:30:35
|
What you are talking about is the GRAPHICAL representation of the money value. It has NOTHING to do with it's value.It's a presentation issue. N 56°04'39.26"E 12°55'05.63" |
|
|
Devart
Posting Yak Master
102 Posts |
Posted - 2010-08-06 : 06:34:22
|
Hello,For example:select replace(convert(varchar(100),convert(decimal(32,2),1235353536586647567.00),1),'.',',');Best regards,Devart,SQL Server Tools:dbForge Schema ComparedbForge Data ComparedbForge Query Builder |
|
|
velliraj
Yak Posting Veteran
59 Posts |
Posted - 2010-08-06 : 06:37:30
|
Sorry deva,I need the result set in this format12,353,535.00above format i was not able to get if i use the decimal conversion. |
|
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2010-08-06 : 07:47:13
|
[code]CREATE FUNCTION dbo.fnDoMyPresentationFormatting( @Value DECIMAL(32, 2))RETURNS VARCHAR(50)ASBEGIN DECLARE @s VARCHAR(50), @ptr SMALLINT SELECT @s = CAST(@Value AS VARCHAR(50)), @ptr = DATALENGTH(@s) - 5 WHILE @ptr >= 1 SELECT @s = STUFF(@s, @ptr, 0, ','), @ptr = @ptr - 3 RETURN @sENDGODECLARE @Value DECIMAL(32, 2) = 1235353536586647567SELECT dbo.fnDoMyPresentationFormatting(@Value)GO[/code] N 56°04'39.26"E 12°55'05.63" |
|
|
|
|
|
|
|