Solved

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

Posted on 2014-12-08
2
6 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
2 Comments
 
LVL 142

Accepted Solution

by:
Guy Hengel [angelIII / a3] earned 500 total points
Comment Utility
' 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

What is SQL Server and how does it work?

The purpose of this paper is to provide you background on SQL Server. It’s your self-study guide for learning fundamentals. It includes both the history of SQL and its technical basics. Concepts and definitions will form the solid foundation of your future DBA expertise.

Join & Write a Comment

Long way back, we had to take help from third party tools in order to encrypt and decrypt data.  Gradually Microsoft understood the need for this feature and started to implement it by building functionality into SQL Server. Finally, with SQL 2008, …
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 …
This video discusses moving either the default database or any database to a new volume.
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.

743 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

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now