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 7867743
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T00:47:24+00:00 2026-06-03T00:47:24+00:00

I try to do a migration but i have problem with this query :

  • 0

I try to do a migration but i have problem with this query :

$DB->query("replace into periodetojour(idperiode,idjour,heure)
            values('".addslashes($idperiode)."','2','".addslashes($mardi)."')");

I saw that REPLACE INTO can’t be used in SQL Server 2008 and that i hav to use MERGE INTO

My problem is that i don’t find any of my query which is working by using MERGE INTO so i am probably not using it well. Do you have any idea how can i change it with MERGE INTO and is it an obligation to change it in SQL Server 2008 ?

Thanks for your answer.

  • 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-03T00:47:25+00:00Added an answer on June 3, 2026 at 12:47 am

    In your case, the MERGE statement would look like this:

    $DB->query("MERGE INTO periodetojour dst 
                USING ( 
                  SELECT '".addslashes($idperiode)."' idperiode, 
                         '2' idjour, 
                         '".addslashes($mardi)."' heure 
                ) src  
                ON src.idperiode = dst.idperiode  
                WHEN MATCHED THEN UPDATE SET  
                  dst.idjour = src.idjour, 
                  dst.heure = src.heure  
                WHEN NOT MATCHED THEN INSERT (idperiode, idjour, heure)  
                  VALUES(src.idperiode, src.idjour, src.heure)");
    

    This is assuming that idperiode is your primary key. If the primary key is composed of (idperiode, idjour) you’ll have to adapt the ON clause as well as the WHEN MATCHED THEN UPDATE SET clause accordingly:

                -- [...]
                ON src.idperiode = dst.idperiode  
                AND src.idjour = dst.idjour
                WHEN MATCHED THEN UPDATE SET  
                  dst.heure = src.heure
                -- [...]
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've been trying to solve this problem for a couple of hours but I
I try to do a migration from MYSQL to SQL Server 2008 but i
Try running this in a .VBS file MsgBox(545.14-544.94) You get a neat little answer
Im a C# developer whom is new to Objective C and this migration has
I've never had anything but success w/ Rails migrations, so this one is especially
I have a migration that will dynamically create tables on fly per date. Something
First of all, I'm using Rails3 with Ruby 1.9.2. I have a problem using
After install Devise I try to run **rake db:migrate** but it gives: **rake aborted!
I have a very simple migration which was created using the generator class AddEmailToUsers
I'm migrating an older .net application to .net 4, this migration has to be

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.