June 24, 2004 at 2:47 am
Hi all,
I have a simple problem really, but my knowledge is very limited at the moment.
My question is as follows.
I have two tables, 1 in database A and the other in Database B. Each table is identical except that the table in A has a column which must be int, whilst the column in B is varchar but does contain numeric values (i.e 68900, 67800 etc).
How can I import only the numeric values into table A from Table B.
I can figure out the import of data, but my sql knowledge as I have said is very limited and so I need your expertise.
Cheers.
June 24, 2004 at 2:57 am
Hi!
If you have all numeric values only in that column of your table it can be inserted without any special handeling, I have given an example pls try this...
Probably this will answer your query.....
create table #t1 (a int)
create table #t2 (b varchar(2))
insert into #t1 select 1
insert into #t2 select 5
insert into #t1 select * from #t2
select * from #t1
Indu Jakhar
June 24, 2004 at 2:01 pm
To expand on Indu Jakhar's response, in order to eliminate non-numerics -
create table #t1 (a int)
create table #t2 (b varchar(2))
insert into #t2 select 1
insert into #t2 select 'a'
insert into #t2 select 5
insert into #t1
select *
from #t2
where isnumeric(#t2.b) = 1
select * from #t1
-- Steve
June 25, 2004 at 2:06 am
Hi all.
Thanks for the replies, and they helped me with this problem.
I managed to get the data I wanted in a roundbout way and it worked fine.
Thanks again.
Viewing 4 posts - 1 through 3 (of 3 total)
You must be logged in to reply to this topic. Login to reply