Solved

Cannot convert a char value to money. The char value has incorrect syntax.

Posted on 2009-05-14
5
1,686 Views
Last Modified: 2012-06-27
I have a sp that sends out email and works great.  But today I added a database column to the sp called q1fine that has a set datatype of money on the server, but when I incorporate the column into the sp, I get an error of the following...

Cannot convert a char value to money. The char value has incorrect syntax.

here is the sp..

Any ideas would be very much appreciated!


declare
@Email varchar(100),
@body varchar(max),
@q1 varchar(100),
@q1qty varchar(8),
@q1fine money,
DECLARE  CursorTemplate CURSOR
FAST_FORWARD FOR       
select email,q1,q1qty,q1fine
FROM my_view
OPEN CursorTemplate
FETCH NEXT FROM CursorTemplate
INTO      @Email,@q1,@q1qty,@q1fine
WHILE (@@FETCH_STATUS = 0)
BEGIN

Set @body =
'<html>' + case when @q1 like '%*%' then '<font color="red">' + @q1 + ' ** ' + @q1qty + ' ' + 'Total - ' + @q1fine + '</font>' else @q1 end + '<br>' +'</html>'
0
Comment
Question by:H-SC
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
5 Comments
 
LVL 75

Accepted Solution

by:
Aneesh Retnakaran earned 500 total points
ID: 24386663
You should convert the Money datatype to varchar before adding it to the string


Set @body =
'' + case when @q1 like '%*%' then '' + @q1 + ' ** ' + @q1qty + ' ' + 'Total - ' +CAST( @q1fine  as  varchar(20)  )  + '' else @q1 end + '
' +''
0
 
LVL 1

Author Comment

by:H-SC
ID: 24387371
aneeshattingal,

I think that I am on the right path using your suggestion....When I do that, It shows the cents and that is ok but does not show the comma

what I am getting now is 2500.00
I would like to get 2,500.00

any ideas
0
 
LVL 75

Expert Comment

by:Anthony Perkins
ID: 24387407
Use (no points please):

CONVERT(varchar(20), @q1fine, 1)
0
 
LVL 1

Author Comment

by:H-SC
ID: 24388549
acperkins,

Perfect!!!
0
 
LVL 1

Author Comment

by:H-SC
ID: 24388556
many many thanks
0

Featured Post

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Everyone has problem when going to load data into Data warehouse (EDW). They all need to confirm that data quality is good but they don't no how to proceed. Microsoft has provided new task within SSIS 2008 called "Data Profiler Task". It solve th…
In the first part of this tutorial we will cover the prerequisites for installing SQL Server vNext on Linux.
This video shows how to set up a shell script to accept a positional parameter when called, pass that to a SQL script, accept the output from the statement back and then manipulate it in the Shell.
Viewers will learn how to use the INSERT statement to insert data into their tables. It will also introduce the NULL statement, to show them what happens when no value is giving for any given column.

739 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question