April 1, 2013 at 8:00 am
Hello,
Since I'm not a programmer and hopefully there's a simply way...
I need to load one column from an excel file into a database table while trying to match the corresponding columns :unsure:
1) I have 3 columns in the excel with a server , account and account description column
2) The database table has these same columns but the account description is BLANK
3) I need to populate the account description from the excel from the corresponding row.
I hope i'm clear
many thx
April 1, 2013 at 8:37 am
Simple way: Use the import wizard in SSMS to load the data into a temp table.
Then use a query to match up the data. If you temp table is MyStage and your regular table is Accounts, I'd run a select first
select
a.server
, a.account
, a.description
, b.server
, b.account
, b.description
from accounts a
inner join Mystage b
on a.server = b.server
and a.account = b.account
This will show you the contents of your account and staging tables as they match up. If this is right, you can update the account table like this:
update a
set a.description = b.description
from accounts a
inner join Mystage b
on a.server = b.server
and a.account = b.account
Then use the first statement to check things.
Drop the staging table when you are done.
April 1, 2013 at 9:32 am
Much appreciated !
I actually tried it the import data wizard and recreated the table with the necessary columns by loading all the respective rows... now I will just work from there instead of comparing the rows.
Will also try it the way you mention
thx
Viewing 3 posts - 1 through 2 (of 2 total)
You must be logged in to reply to this topic. Login to reply
This website stores cookies on your computer.
These cookies are used to improve your website experience and provide more personalized services to you, both on this website and through other media.
To find out more about the cookies we use, see our Privacy Policy