Solved

SQL Update

Posted on 2012-03-27
3
390 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
Comment Utility
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 39

Accepted Solution

by:
Kyle Abrahams earned 250 total points
Comment Utility
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
Comment Utility
Thank you
0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Everyone has problem when going to load data into Data warehouse (EDW). They all need to confirm that data quality is good but they don't no how to proceed. Microsoft has provided new task within SSIS 2008 called "Data Profiler Task". It solve th…
In this article we will get to know that how can we recover deleted data if it happens accidently. We really can recover deleted rows if we know the time when data is deleted by using the transaction log.
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.
Via a live example, show how to setup several different housekeeping processes for a SQL Server.

771 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

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now