Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics CRM (Archived)

Insert or Update records while dumping data

(0) ShareShare
ReportReport
Posted on by 795

Hi,

I am using "Insert into Select" statement for dumping data from one database to other in one go.But, how can i write my query if i want to update records which once already inserted and insert new records which are not there.

*This post is locked for comments

  • Verified answer
    CRM Beginner  Profile Picture
    CRM Beginner 795 on at
    RE: Insert or Update records while dumping data

    Thank you everyone..It worked using Merge ... But a doubt is there..Is merge will work fine in case i will be working for two tables on different servers using linked server ?

  • Suggested answer
    ashlega Profile Picture
    ashlega 34,477 on at
    RE: Insert or Update records while dumping data

    Are you using CRM online(as indicated in the "Tags") or on-prem?

    Either way, that's kind of not recommended with CRM to do direct SQL inserts since you may miss some relationships and, then, the whole CRM database will be out of sync.

    But, to answer your question, I guess you might do something like this:

    stackoverflow.com/.../how-to-upsert-update-or-insert-in-sql-server-2005

  • Suggested answer
    Mahendar Pal Profile Picture
    Mahendar Pal 45,095 on at
    RE: Insert or Update records while dumping data

    Hi,

    You need to use Upsert, which update existing record if reference found otherwise it will created that record.

  • Suggested answer
    Adrian Begovich Profile Picture
    Adrian Begovich 1,019 Super User 2025 Season 1 on at
    RE: Insert or Update records while dumping data

    Hi CRM Beginner,

    You can do this with a Merge/Upsert.

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Daivat Vartak – Community Spotlight

We are honored to recognize Daivat Vartak as our March 2025 Community…

Announcing Our 2025 Season 1 Super Users!

A new season of Super Users has arrived, and we are so grateful for the daily…

Kudos to the February Top 10 Community Stars!

Thanks for all your good work in the Community!

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 292,516 Super User 2025 Season 1

#2
Martin Dráb Profile Picture

Martin Dráb 231,407 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans