[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

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

Update all records in one column with data from the first record in another table

I am  looking to update all the rows of one column in a table with the value in a the first row in a seperate table.
I have tried
UPDATE       InputGlobalFeed
SET                IGFMerchantName = AWHeader.AWMerchantName
FROM            AWHeader CROSS JOIN
                         InputGlobalFeed

But this updates IGFMerchantName from  InputGlobalFeed with various record from AWHeader and not just AWMerchantName.
Many thanks
0
Simon Cripps
Asked:
Simon Cripps
1 Solution
 
sunithnairCommented:
Try this query

UPDATE InputGlobalFeed
SET IGFMerchantName = (SELECT TOP 1 AWMerchantName FROM AWHeader)
0
 
tigin44Commented:
try this
UPDATE T1
SET T1.IGFMerchantName = T2.AWMerchantName
FROM InputGlobalFeed T1,
	(SELECT TOP 1 AWMerchantName FROM AWHeader) T2

Open in new window

0
 
Simon CrippsAuthor Commented:
many thanks Sunithnair, thought it was something like this but just could not nail it. Cheers
0

Featured Post

How to Use the Help Bell

Need to boost the visibility of your question for solutions? Use the Experts Exchange Help Bell to confirm priority levels and contact subject-matter experts for question attention.  Check out this how-to article for more information.

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