Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/sql-server-2008/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/algorithm/11.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Mysql 在SQL Server 2008中替换为_Mysql_Sql Server 2008_Migration - Fatal编程技术网

Mysql 在SQL Server 2008中替换为

Mysql 在SQL Server 2008中替换为,mysql,sql-server-2008,migration,Mysql,Sql Server 2008,Migration,我尝试进行迁移,但我对此查询有问题: $DB->query("replace into periodetojour(idperiode,idjour,heure) values('".addslashes($idperiode)."','2','".addslashes($mardi)."')"); 我发现在SQL Server 2008中不能使用REPLACE-INTO,我必须使用MERGE-INTO 我的问题是,我找不到任何使用合并到的查询,因此我可能没有很好

我尝试进行迁移,但我对此查询有问题:

$DB->query("replace into periodetojour(idperiode,idjour,heure)
            values('".addslashes($idperiode)."','2','".addslashes($mardi)."')");
我发现在SQL Server 2008中不能使用
REPLACE-INTO
,我必须使用
MERGE-INTO

我的问题是,我找不到任何使用
合并到
的查询,因此我可能没有很好地使用它。您知道如何使用MERGE-INTO进行更改吗?在SQLServer2008中是否有义务进行更改

谢谢您的回答。

在您的情况下,声明如下所示:

$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)");
这是假设
idperiode
是您的主键。如果主键由
(idperiode,idjour)
组成,则必须调整
ON
子句以及匹配时的
,然后相应地更新SET
子句:

            -- [...]
            ON src.idperiode = dst.idperiode  
            AND src.idjour = dst.idjour
            WHEN MATCHED THEN UPDATE SET  
              dst.heure = src.heure
            -- [...]

您正在尝试将数据从一个表迁移到另一个表吗?不确定我是否理解您的问题。您是否正在寻找使用
合并
的方法?我不是sql server用户,但已找到。