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!

Loading data from Excel

Status
Not open for further replies.

sinCity99

Programmer
Jan 21, 2009
20
US
I have 2 columns from an excel sheet that is in the order that i want to reorder my table into.

Example:
my current table A:
pat 2
ryan 33
bob 45
chris 6

My excel sheet has the correct sequence:
pat 33
ryan 6
bob 2
chris 45

How can i update my table A so that it matches my excel sheet? Do I have to update each individual line because i actually have 100s of these to update?
 
1. Import the excel sheet into a table.
2. Right the update to the number on the join of the sql object to the imported object.

Code:
create table tbl1
(fname varchar(20),num int)

create table importtbl
(fname varchar(20),num int)


insert into tbl1 
values ('pat',2),('ryan',33),('bob',45),('chris',6)

insert into importtbl 
values ('pat',33),('ryan',6),('bob',2),('chris',45)

update a
set num = b.num
from tbl1 a
join importtbl b on a.fname = b.fname
 
Thanks!....what if i have like 800 of these values? how do i upload them (the values)?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top