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;

    If you haven't even tried to resolve your issue, please don't expect the hard-working volunteers here to waste their time providing links to answers which you could easily have found yourself.

  • 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