Solved

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

Posted on 2014-12-08
2
15 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 143

Accepted Solution

by:
Guy Hengel [angelIII / a3] earned 500 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

Complete VMware vSphere® ESX(i) & Hyper-V Backup

Capture your entire system, including the host, with patented disk imaging integrated with VMware VADP / Microsoft VSS and RCT. RTOs is as low as 15 seconds with Acronis Active Restore™. You can enjoy unlimited P2V/V2V migrations from any source (even from a different hypervisor)

Question has a verified solution.

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

After restoring a Microsoft SQL Server database (.bak) from backup or attaching .mdf file, you may run into "Error '15023' User or role already exists in the current database" when you use the "User Mapping" SQL Management Studio functionality to al…
If you have heard of RFC822 date formats, they can be quite a challenge in SQL Server. RFC822 is an Internet standard format for email message headers, including all dates within those headers. The RFC822 protocols are available in detail at:   ht…
Two types of users will appreciate AOMEI Backupper Pro: 1 - Those with PCIe drives (and haven't found cloning software that works on them). 2 - Those who want a fast clone of their boot drive (no re-boots needed) and it can clone your drive wh…
Established in 1997, Technology Architects has become one of the most reputable technology solutions companies in the country. TA have been providing businesses with cost effective state-of-the-art solutions and unparalleled service that is designed…

789 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