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 |
|
Trininole
Yak Posting Veteran
83 Posts |
Posted - 2010-09-15 : 10:21:48
|
| How do i join two different tables with the same column name that have different data types? For example how would i join two tables with the column name "idnum" with one table having the column name as a numeric data type and the other table having the column name as an integer data type?Roger DeFour |
|
|
kashyap.2000
Starting Member
22 Posts |
Posted - 2010-09-15 : 10:31:15
|
| Convert one of the columns to other data type while joining. for instance .... select * from table1 t1 join table2 t2 on (t1.column1=cast(t2.column as integer)) |
 |
|
|
rohitvishwakarma
Posting Yak Master
232 Posts |
Posted - 2010-09-15 : 10:47:44
|
| If it is SQL Server 2008No need to CAST. just write the JOIN as usual without any casting i.e.SELECT * FROM Table1 INNER JOIN Tabl2 ON Table1.common_column = Table2.common_columnI have tested it with the Int,Varchar & Int,Numeric combinations and it works fine. |
 |
|
|
X002548
Not Just a Number
15586 Posts |
|
|
|
|
|