updating one table using data from another

  • I'm trying to update my table[Provider_DB].[dbo].[ContinuingEdProvider] with data from my other table [Provider_DB].[dbo].[MasterProviderList] but my syntax is wrong... any ideas?:
    UPDATE [Provider_DB].[dbo].[ContinuingEdProvider] a
    SET a.[ContactFName] = b.[FirstName],
      a.[ContactLName] = b.[LastName]
    FROM (
      SELECT b.[ProviderId], b.[FirstName], b.[LastName]
      FROM [Provider_DB].[dbo].[MasterProviderList] b)
    WHERE
      a.[ProviderId] = b.[ProviderId]

  • briancampbellmcad - Friday, June 15, 2018 10:54 AM

    I'm trying to update my table[Provider_DB].[dbo].[ContinuingEdProvider] with data from my other table [Provider_DB].[dbo].[MasterProviderList] but my syntax is wrong... any ideas?:
    UPDATE [Provider_DB].[dbo].[ContinuingEdProvider] a
    SET a.[ContactFName] = b.[FirstName],
      a.[ContactLName] = b.[LastName]
    FROM (
      SELECT b.[ProviderId], b.[FirstName], b.[LastName]
      FROM [Provider_DB].[dbo].[MasterProviderList] b)
    WHERE
      a.[ProviderId] = b.[ProviderId]

    Something like this?
    UPDATE a
    SET
       a.ContactFName = b.FirstName
    ,  a.ContactLName = b.LastName
    FROM
       Provider_DB.dbo.ContinuingEdProvider a
    JOIN Provider_DB.dbo.MasterProviderList b ON a.ProviderId = b.ProviderId;

    The absence of evidence is not evidence of absence
    - Martin Rees
    The absence of consumable DDL, sample data and desired results is, however, evidence of the absence of my response
    - Phil Parkin

  • Thank you that makes much more sense and works!

Viewing 3 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic. Login to reply