0

I have this part of query that causes the above error:

CONVERT(varchar(15),CAST((AmountOfInsurance) as MONEY),1)

What am I doing worng?

This is the declararion of AmountOfInsurance

AmountOfInsurance decimal(19,2),
7
  • hi , what is value of AmountOfInsurance ? Commented Feb 2, 2017 at 7:07
  • Error message pretty clear. You cannot convert non numeric characters to money. AmountOfInsurance has some non numeric characters Commented Feb 2, 2017 at 7:08
  • can you tell me what is datatype of AmountOfInsurance ?? Commented Feb 2, 2017 at 7:09
  • can you please post the whole query, from query you are fetching varchar and on code side you have assigned numeric so you are getting above error Commented Feb 2, 2017 at 7:09
  • there is non decimal value as AmountOfInsurance .if AmountOfInsurance is decimal or its is null also work fine . Commented Feb 2, 2017 at 7:11

1 Answer 1

1

I hope this will work for you...

CONVERT(varchar(15), CONVERT(money, AmountOfInsurance), 1)

More information: the last parameter decides what the output format looks like:

  • 0 (default) No commas every three digits to the left of the decimal point, and two digits to the right of the decimal point; for example, 4235.98.

  • 1 Commas every three digits to the left of the decimal point, and two digits to the right of the decimal point; for example, 3,510.92.

  • 2 No commas every three digits to the left of the decimal point, and four digits to the right of the decimal point; for example, 4235.9819.

If you want to truncate the pennies, and count in pounds, you can use rounding to the nearest pound, floor to the lowest whole pound, or ceiling to round up the pounds

Sign up to request clarification or add additional context in comments.

4 Comments

This is plagiarism. Please do NOT copy word for word from other answers but instead comment that they are duplicates.
@mplungjan, Lots of posts mention that stackoverflow.com/… .... Looks like it is all plagiarized from a single source.
This is the second copy of a post I have seen from this user
@mplungjan i accept my apology for that..now onwards i will take care this things..

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.