Change a tables datatype in a Column for Joining

General
Enthusiast

Change a tables datatype in a Column for Joining

Hi Forum,

I have 2 tables, with a Month_Id written as '201310' to denote October 2013 for example.

Problem is, I have one table with this Column created as an Integer & another as a Varchar. 

What is the best way to change one of them to to other so I can join them?

Thanks

5 REPLIES
Teradata Employee

Re: Change a tables datatype in a Column for Joining

Hi,

an integer would require less storage than a varchar.   Also, the join would be slightly faster.  From this point of view, it is better change varchar to integer.  

Regards,

Vlad.

Enthusiast

Re: Change a tables datatype in a Column for Joining

Hi,

I agree with Vlad, if you convert the varchar column to Integer, the join will become much fast, and also storage will be saved. you can go for integer. 

Khurram
Enthusiast

Re: Change a tables datatype in a Column for Joining

Thank you, I will take that option but how do I do this?

Enthusiast

Re: Change a tables datatype in a Column for Joining

I've created a workaround to achieve what I needed.

I added another Mon_Yr Column as an INTEGER datatype & then added an UPDATE statement to make the new 'Mon_Yr' Column = the Old One. 

Is there an easier way to do this??

Teradata Employee

Re: Change a tables datatype in a Column for Joining

Well, i were thinking about writing either "much faster" or "slightly faster", and left the phrase "slightly faster" just to avoid any special expectations/commitments.    I've seen cases in the field where it was, indeed, much faster. 

Yes it should be a separate column - either in addition to the existing one, or instead of it.

Regards,

Vlad.