[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 410
  • Last Modified:

SQL Update

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
garethtnash
Asked:
garethtnash
2 Solutions
 
CluskittCommented:
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
 
Kyle AbrahamsSenior .Net DeveloperCommented:
update ma
set ma.<col> = au.<col>
from Member-Address ma
join addressupload au on
ma.MemberID = au.memberID
0
 
garethtnashAuthor Commented:
Thank you
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now