SQL Server 2005 implementation of MySQL REPLACE INTO?

后端 未结 4 1338
星月不相逢
星月不相逢 2020-12-04 14:57

MySQL has this incredibly useful yet proprietary REPLACE INTO SQL Command.

Can this easily be emulated in SQL Server 2005?

Starting a new Trans

4条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2020-12-04 15:32

    The functionality you're looking for is traditionally called an UPSERT. Atleast knowing what it's called might help you find what you're looking for.

    I don't think SQL Server 2005 has any great ways of doing this. 2008 introduces the MERGE statement that can be used to accomplish this as shown in: http://www.databasejournal.com/features/mssql/article.php/3739131 or http://blogs.conchango.com/davidportas/archive/2007/11/14/SQL-Server-2008-MERGE.aspx

    Merge was available in the beta of 2005, but they removed it out in the final release.

提交回复
热议问题