Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Conversion failed when converting the varchar value '')' to data type int

Posted on 2014-12-08
2
Medium Priority
?
27 Views
Last Modified: 2016-06-16
I have a query below , in that with out count function .i got answer,if using count function ,i got this error ---->Conversion failed when converting the varchar value '')' to data type int.
 
Please crack me out..
 

 

select 'INSERT INTO CM_ONTHEFLYCOMMUNICATION (c_source,c_classification,c_name,c_email,c_mobile,c_bookscount)
values ( '''+'Library'+''','''+isnull('CheckOut -'+cio_branchname,'')+''',
'''+ISNULL(cio_membername,'')+''','''+ISNULL(mstmember.m_email1,'')+''',
'''+ISNULL(mstmember.m_mobile,'')+''','''+count(trncheckinout.cio_bookname)+''')'
 
AS MAILQRY
from
trncheckinout inner join
mstmember on cio_mrecid=m_recid where CIO_CheckOutDt = 20141208
group by m_email1,m_mobile, cio_branchname,cio_membername









I want o/p like this sir, please see Below .. In that at last you see 'THE SURVIVORS CLUB' <-- its a book, i want count of that .. so only i structured query like that,so i used count function there..Thank you
 
INSERT INTO CM_ONTHEFLYCOMMUNICATION (c_source,c_classification,c_name,c_email,c_mobile,c_bookscount)
values ( 'Library','CheckOut -seevaram ',
'D253,RAMYA DEVI BRAMYA DEVI B','rami.rogfed@gmail.com',
'+919445354610','THE SURVIVORS CLUB')
0
Comment
1 Comment
 
LVL 143

Accepted Solution

by:
Guy Hengel [angelIII / a3] earned 2000 total points
ID: 40488340
' xxx ' + int_field +  'xxx'
will give that error; to fix:
 ' xxx ' + cast(int_field as varchar(100)) +  'xxx'

and it will work
0

Featured Post

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

Question has a verified solution.

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

Naughty Me. While I was changing the database name from DB1 to DB_PROD1 (yep it's not real database name ^v^), I changed the database name and notified my application fellows that I did it. They turn on the application, and everything is working. A …
Occasionally there is a need to clean table columns, especially if you have inherited legacy data. There are obviously many ways to accomplish that, including elaborate UPDATE queries with anywhere from one to numerous REPLACE functions (even within…
In response to a need for security and privacy, and to continue fostering an environment members can turn to for support, solutions, and education, Experts Exchange has created anonymous question capabilities. This new feature is available to our Pr…
Screencast - Getting to Know the Pipeline

824 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