Thursday, August 1, 2013

At least one column contains matching value

if val1, val2, val3.... are integer data types, then the below one will work



select *
from <your table>
where (val1+val2+val3+val4+val5+val6) > 0

if they are string data types then the below on is the best



select *
from <your table>
where val1+val2+val3+val4+val5+val6 LIKE '%1%'

if they are any other data types, then add convert statements to either string or integer to the above statements.


something like cast(val1 as int) + cast(val2 as int) + ...... >




Nothing is Permanent... even Knowledge.... <a href="http://everysolution.wordpress.com/"> </a>


No comments:

Post a Comment