J Singh
J Singh

Reputation: 1

Convert varchar to tinyint(4) in mysql stored procedure

I am migrating data from one data base to another data base. In first data base there is a table lets say table1, has a field of type varchar(100) with value "White" and in another data base there is a table lets table2 has the same field of type tinyint(4), so, how can I convert varchar to tinyint. I searched a lot but didn't find any relevant info. Please help. Thanks in advance.

Upvotes: 0

Views: 4462

Answers (1)

Techy
Techy

Reputation: 2654

I am unaware of the integer value of varchar value 'white'. Normally we can convert varchar value to int like the folowing query

select cast(column_name as tinyint)  

EDIT: Spaces will not be a problem for cast, however characters like TAB, CR or LF will appear as spaces,use REPLACE to clean up your data.

Upvotes: 1

Related Questions