Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

change number to text for join

Status
Not open for further replies.

geckodfw

Technical User
Oct 12, 2001
17
US
I have 2 tables that I need to join, one table has a field called "Bill_To" which is a number field. It corresponds to another table in the same database where it is called "recv_acct_id" and is text. There is no indexing or calculation needed. I just need the two to join. Is there a simple way?!

Thanks
 
Here are some suggestions. Choose the one that fits your need.

Select t1.col1, t1.col2, t2.colA, t2.colB, ...
From table1 t1
Inner Join table2 t2
On t1.NumCol=convert(int, t2.txtCol)

Select ...
From table1 t1
Inner Join table2 t2
On convert(varchar(12), t1.numcol)=t2.txtcol

You may need to manipulate the conversions to account for leading zeros in the text column. Terry L. Broadbent - DBA
faq183-874 contains "Suggestions for Getting Quick and Appropriate Answers."
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top