Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Updating columns

Author  Topic 

junior6202
Starting Member

45 Posts

Posted - 2014-09-30 : 12:21:54
Hi All,

I am noob in to Sql, I know how to perform a simple update statement but I have this task I have to perform where I was given an excel worksheet with over 3000 part numbers that have changed location and and location number. example :

PartNum, Location, LocationNum

cc12345, A2 , A2-123

If there where just a few I could just write a simple update query but there are a few thousand records like I mention before. Can you give me an idea on how to accomplish this task please. Thanks in advance.

Bustaz Kool
Master Smack Fu Yak Hacker

1834 Posts

Posted - 2014-09-30 : 13:23:08
Can you import the excel into SQL in some manner? (Here is a link to setting up a linked server to your excel sheet: http://support.microsoft.com/kb/306397) Once you have that...
update m
set Location = x.Location,
LocationNum = x.LocationNum
from
MyTable m
inner join
YourExcelTable x
on m.PartNum = x.PartNum
You'll need to define how the Excel table appears and change the table names accordingly.



Too often we enjoy the comfort of opinion without the discomfort of thought. - John F. Kennedy
Go to Top of Page

junior6202
Starting Member

45 Posts

Posted - 2014-10-01 : 11:36:37
Thanks Bustaz Kool, for the help. I imported the Excel file to SQL server and modified the query and it worked wonderfully.
Go to Top of Page
   

- Advertisement -