What is the best implementation of MySQL for SQL Server 2005?
--try an update update tablename set field1 = "new value", field2 = "different value", ... where idfield = 7 --insert if failed if @@rowcount = 0 and @@error = 0 insert into tablename ( idfield, field1, field2, ... ) values ( 7, "value one", "another value", ... )
merge tablename as target using (values ("new value", "different value")) as source (field1, field2) on target.idfield = 7 when matched then update set field1 = source.field1, field2 = source.field2, ... when not matched then insert ( idfield, field1, field2, ... ) values ( 7, source.field1, source.field2, ... )
This code snippet was collected from stackoverflow, and is licensed under CC BY-SA 4.0
- Binary data in MySQL.
- What is a change to SQL Server tables?
- How do I upgrade my SQL Server database version?
- MySQL and Python are both well written programmers.
- The ability to edit a database by multiple users is essential.
- How do you copy a data base?
- How do I unit test persistence?
- Convert HashBytes to VarChart?
- How do I divide a string so I can access item x?
- How do you get the data from a temporary table in SQL Server?
- What do you need to escape when submitting a question?
- How do I use T-SQL group?
- How much disk space does a SQL Server table currently use?
- Can you remove the time portion of a datetime value?
- What do you need to do for XML files?