Solved

SQL Update

Posted on 2012-03-27
3
397 Views
Last Modified: 2012-03-27
Hi,

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


AND

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
) ON [PRIMARY]

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 -

Thanks
0
Comment
Question by:garethtnash
3 Comments
 
LVL 18

Assisted Solution

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

Accepted Solution

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

Author Closing Comment

by:garethtnash
ID: 37772224
Thank you
0

Featured Post

NAS Cloud Backup Strategies

This article explains backup scenarios when using network storage. We review the so-called “3-2-1 strategy” and summarize the methods you can use to send NAS data to the cloud

Question has a verified solution.

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

In this article I will describe the Backup & Restore method as one possible migration process and I will add the extra tasks needed for an upgrade when and where is applied so it will cover all.
Ever wondered why sometimes your SQL Server is slow or unresponsive with connections spiking up but by the time you go in, all is well? The following article will show you how to install and configure a SQL job that will send you email alerts includ…
This video shows, step by step, how to configure Oracle Heterogeneous Services via the Generic Gateway Agent in order to make a connection from an Oracle session and access a remote SQL Server database table.
Viewers will learn how the fundamental information of how to create a table.

860 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