Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
Solved

# int and varchar joined

Posted on 2011-03-17
Medium Priority
402 Views
join an int and varchar column

but the column that is varchar has words sometimes
I do not want that joined

0
Question by:rgb192
[X]
###### Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

• Help others & share knowledge
• Earn cash & points
• 2

LVL 32

Accepted Solution

Ephraim Wangoya earned 1000 total points
ID: 35160427

select *
from tableA
inner join TableB on ( (Cast(TableB.Varhcharfield as Integer) = TableA.IntegerField)
and (ISNUMERIC(TableB.Varhcharfield) = 1))
0

LVL 41

Assisted Solution

Sharath earned 1000 total points
ID: 35160714
ewangoya, converting to int will fail if the asker has , or . in the data. check this example by converting to INT.
I prefer converting to MONEY in such cases.
``````declare @table1 table(col1 int)
declare @table2 table(col2 varchar(10))
insert @table1 values(10),(20)
insert @table2 values ('10'),('23.00'),('123,234'),('invalid')
select *
from @table1 t1
join @table2 t2
on t1.col1 = convert(money,t2.col2)
where ISNUMERIC(t2.col2) = 1
``````
0

LVL 32

Expert Comment

ID: 35161201

True, we acquire more knowledge each day.
0

Author Closing Comment

ID: 35165819
thanks
0

## Featured Post

Question has a verified solution.

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

I am showing a way to read/import the excel data in table using SQL server 2005... Suppose there is an Excel file "Book1" at location "C:\temp" with column "First Name" and "Last Name". Now to import this Excel data into the table, we will use…
So every once in a while at work I am asked to export data from one table and insert it into another on a different server.  I hate doing this.  There's so many different tables and data types.  Some column data needs quoted and some doesn't.  What …
Monitoring a network: how to monitor network services and why? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the philosophy behind service monitoring and why a handshake validation is critical in network monitoring. Software utilized …
How to fix incompatible JVM issue while installing Eclipse While installing Eclipse in windows, got one error like above and unable to proceed with the installation. This video describes how to successfully install Eclipse. How to solve incompa…
###### Suggested Courses
Course of the Month6 days, 13 hours left to enroll