Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8446461
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T09:56:26+00:00 2026-06-10T09:56:26+00:00

I have found a way to make two tables from different databases match each

  • 0

I have found a way to make two tables from different databases match each other using this template:

INSERT [DestDB].[dbo].[TABLE]
SELECT source.* FROM 
[SourceDB].[dbo].[TABLE] AS source
LEFT OUTER JOIN
[DestDB].[dbo].[TABLE] AS dest
ON 
source.[PKColumn] = dest.[PKColumn]
WHERE dest.[PKcolumn] IS NULL

UPDATE dest
SET 
 dest.[PK_COLUMN1] = source.[PK_COLUMN1]
,dest.[COLUMN2] = source.[COLUMN2]
,dest.[COLUMN3] = source.[COLUMN3]
,dest.[COLUMN4] = source.[COLUMN4]
,dest.[COLUMN5] = source.[COLUMN5]
,dest.[COLUMN6] = source.[COLUMN6]
,dest.[COLUMN7] = source.[COLUMN7]
,dest.[COLUMN8] = source.[COLUMN8]

FROM 
[SourceDB].[dbo].[TABLE] AS source
INNER JOIN 
[DestDB].[dbo].[TABLE] AS dest
ON source.[PK_Column1] = dest.[PK_Column1]

However some tables I am working with have at least 200 columns and while it is possible to do this through the power of Copy + Paste, I just need to know if there is a way that doesn’t involve me getting Carpel Tunnel Syndrome.

I am using Microsoft SQL Server 2005.

Any advice?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-10T09:56:28+00:00Added an answer on June 10, 2026 at 9:56 am

    I don’t think you can update columns without naming them, but you can use SQL and the sys.columns view to script it for you:

    select ',dest.[' + name + '] = source.[' + name +']' 
    from sys.columns 
    WHERE object_id = OBJECT_ID(N'[dbo].[Widgets]')
    

    — output —

    ,dest.[WidgetId] = source.[WidgetId]
    ,dest.[WidgetName] = source.[WidgetName]
    ,dest.[CreatedDt] = source.[CreatedDt]
    ,dest.[WidgetValue] = source.[WidgetValue]
    ,dest.[ModifiedDt] = source.[ModifiedDt]
    

    The only other way is to NOT update, but instead truncate the dest table and perform a SELECT INTO

    SELECT * INTO DEST FROM SOURCE
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This is my scenario: I have two different tables: Table 'subscriptions' contains all the
I've been trying to find a way to do this but, have not found
Does anybody know, how to make chart like this? I have not found any
I have two tables, records are being continuously inserted to these tables from outside
I have found a way to change a property in TeamCity: ##teamcity[setParameter name='ddd' value='fff']
I have found the way to copy the record that I would like, but
okay i have found the way to run a video in a image.... the
I have not found any way to successfully set a screen resolution on my
I'm hacking my way through learning Flex and have found some strange behaviour. When
I have never found a neat(er) way of doing the following. Say I have

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.