Click here to Skip to main content
15,881,882 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Hello Team,

I have the CustomerLoanData Table
In that table, ColumnName addrverify is varchar .it has to be varchar

Now my problem is when i am firing the select Query as follow . I am getting the error .So how should i solve this .

SQL
select ID,FULLADDRESS,CUSTOMERADDR1,CUSTOMERADDR2,LANDMARK,CITY,STATE, PINCODE from customerloandata
 with (nolock) where CITY =''or STATE ='' or PINCODE = '' and isnull(addrverify,0) = 0


Error : Conversion failed when converting the varchar value 'YES' to data type int.

Thanks
Harshal
Posted

Do this instead

SQL
select ID,FULLADDRESS,CUSTOMERADDR1,CUSTOMERADDR2,LANDMARK,CITY,STATE, PINCODE from customerloandata
 with (nolock) where CITY =''or STATE ='' or PINCODE = '' and isnull(addrverify,'NO') = 'NO'


If addrverify is a varchar, you cannot replace a null value with a number. Stick with the same datatype.
 
Share this answer
 
Comments
R Harshal 22-Feb-14 5:21am    
Thanks for your help.
Because you are trying to

C#
nvarchar(max)=int


try with this:

SQL
select ID,FULLADDRESS,CUSTOMERADDR1,CUSTOMERADDR2,LANDMARK,CITY,STATE, PINCODE from customerloandata
 with (nolock) where CITY =''or STATE ='' or PINCODE = '' and isnull(addrverify,0) =''
 
Share this answer
 
v3
Comments
R Harshal 22-Feb-14 5:22am    
Thanks for your help.
King Fisher 22-Feb-14 5:24am    
welcome

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900