Link to home
Start Free TrialLog in
Avatar of vd
vd

asked on

Convert char 19 column to integer

I have a column of numbers in Table A of data type char (length 19). I would like to copy the entries in this column to another table, Table B, to a column of type integer (long integer).
What would be a good way to do this?
Avatar of simonsabin
simonsabin

You will need to store it as a numeric(19)

i.e
insert into tableb(col1)
select convert(numeric(19),col1) from table1
Avatar of vd

ASKER

There's no such thing as a numeric 19!  Is there...
ASKER CERTIFIED SOLUTION
Avatar of JHausmann
JHausmann

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
One final thing, if your the string of characters that's in your table is less than 11 digits (in the field defined as char(19)) you could do:

insert into tableb(col1)
select convert(int,col1) from table1 where isnumeric(col1) = 1
JHausman

I know you are new so I will let you off but be aware you should never post an answer if someones comment is correct. You should only post an answer if you have the definitive answer and no one has already said it in a comment/answer before. Or you have been asked to post an answer
Avatar of vd

ASKER

Thanks for your thorough explanation.
Thanks...
This question was awarded, but never cleared due to the JSP-500 errors of that time.  It was "stuck" against userID -1 versus the intended expert whom you awarded.  This corrects the problem and the expert will now receive these points; points verified.

Please click on your Member Profile and select "View Question History" to navigate through any open or locked questions you may have to update and finalize them.  If you are an EE Pro user, you can also choose Power Search to find all your open questions.

This is the Community Support link, if help is needed, along with the link to All Topics which reflects many TAs recently added.

https://www.experts-exchange.com/jsp/qList.jsp?ta=commspt
https://www.experts-exchange.com/jsp/zonesAll.jsp
 
Thank you,
Moondancer
Moderator @ Experts Exchange