SQL Update

Posted on 2012-03-27
Medium Priority
Last Modified: 2012-03-27

I have two tables --

CREATE TABLE [dbo].[Member-Address](
	[ID] [int] IDENTITY(1,1) NOT NULL,
	[MemberID] [nvarchar](50) NULL,
	[ClubName] [nvarchar](50) NULL,
	[Address1] [nvarchar](255) NULL,
	[Address2] [nvarchar](255) NULL,
	[Town] [int] NOT NULL,
	[Region] [int] NOT NULL,
	[Locality] [int] NOT NULL,
	[Country] [int] NOT NULL,
	[PostCode] [nvarchar](10) NULL

Open in new window


CREATE TABLE [dbo].[addressupload](
	[MemberID] [int] NULL,
	[Town ID] [float] NULL,
	[RegionID] [float] NULL,
	[LocalityID] [float] NULL,
	[CountryID] [float] NULL,
	[Postcode] [nvarchar](10) NULL,
	[ExchequerID] [nvarchar](10) NULL

Open in new window

I need to update the [Town], [Region], [Locality], [Country], [PostCode] values for each record in [dbo].[Member-Address] with the values in [dbo].[addressupload] where [dbo].[addressupload].[MemberID] is equal to [dbo].[Member-Address].[MemberID]

I'm not so sure how to do this..

Grateful for any assistance -

Question by:garethtnash
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
LVL 18

Assisted Solution

Cluskitt earned 1000 total points
ID: 37771993
SET t.Town=v.[Town ID],
... etc
FROM [Member-Address] t
INNER JOIN addressupload v
ON t.MemberID=v.MemberID
LVL 40

Accepted Solution

Kyle Abrahams earned 1000 total points
ID: 37772004
update ma
set ma.<col> = au.<col>
from Member-Address ma
join addressupload au on
ma.MemberID = au.memberID

Author Closing Comment

ID: 37772224
Thank you

Featured Post

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

JSON is being used more and more, besides XML, and you surely wanted to parse the data out into SQL instead of doing it in some Javascript. The below function in SQL Server can do the job for you, returning a quick table with the parsed data.
Load balancing is the method of dividing the total amount of work performed by one computer between two or more computers. Its aim is to get more work done in the same amount of time, ensuring that all the users get served faster.
Via a live example, show how to shrink a transaction log file down to a reasonable size.
Viewers will learn how to use the UPDATE and DELETE statements to change or remove existing data from their tables. Make a table: Update a specific column given a specific row using the UPDATE statement: Remove a set of values using the DELETE s…

777 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question