Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
ShooterJ07
Starting Member
17 Posts |
Posted - 2007-12-13 : 13:34:24
|
Sorry.. not a very descriptive name for a topic... :)I need to join two tables, but the field (just call it ID) I need to join them on is a different datatype in each table.In Table1, ID is a varchar.In Table2, ID is a bigint.For the most part, the data in Table2 could be a valid bigint... however, there are a few record with bad data. So instead of a number like 123456, it might have DX383FS. Is there any way I can join these two tables? This won't work:SELECT * FROM Table1, Table2 where Table1.ID = Table2.ID |
|
|
jsmith8858
Dr. Cross Join
7423 Posts |
Posted - 2007-12-13 : 13:44:32
|
| convert the bigint column to a varchar in your join expression. And use ANSI join syntax, never express JOINS in your WHERE clause.i.e.,select ..from table1inner join table2 on table1.VarCharCol = convert(varchar(20), table2.BigIntCol)Keep in mind that performance will be very poor due to your table structure.- Jeffhttp://weblogs.sqlteam.com/JeffS |
 |
|
|
ShooterJ07
Starting Member
17 Posts |
Posted - 2007-12-13 : 14:13:21
|
| Perfect. Thanks :) |
 |
|
|
|
|
|