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

Posted on 2010-01-04
Last Modified: 2012-06-27
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

But this updates IGFMerchantName from  InputGlobalFeed with various record from AWHeader and not just AWMerchantName.
Many thanks
Question by:Simon Cripps
    LVL 16

    Accepted Solution

    Try this query

    UPDATE InputGlobalFeed
    SET IGFMerchantName = (SELECT TOP 1 AWMerchantName FROM AWHeader)
    LVL 26

    Expert Comment

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

    Open in new window


    Author Closing Comment

    by:Simon Cripps
    many thanks Sunithnair, thought it was something like this but just could not nail it. Cheers

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Maximize Your Threat Intelligence Reporting

    Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

    Nowadays, some of developer are too much worried about data. Who is using data, who is updating it etc. etc. Because, data is more costlier in term of money and information. So security of data is focusing concern in days. Lets' understand the Au…
    When you hear the word proxy, you may become apprehensive. This article will help you to understand Proxy and when it is useful. Let's talk Proxy for SQL Server. (Not in terms of Internet access.) Typically, you'll run into this type of problem w…
    Via a live example, show how to set up a backup for SQL Server using a Maintenance Plan and how to schedule the job into SQL Server Agent.
    Via a live example, show how to shrink a transaction log file down to a reasonable size.

    760 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

    7 Experts available now in Live!

    Get 1:1 Help Now