|
Posted by Erland Sommarskog on 02/06/07 15:07
Bart op de grote markt (bartwarnez@freegates.be) writes:
> I used to work in a Sybase database environment. When I had to insert/
> update records in the database, I always used "insert on existing
> update", in this way, you didn't have to check whether a record
> already existed (avoid errors) and you were always sure that after
> running the scripts, the last version was in the database.
>
> Now I'm looking for the same functionality in MS SQL Server, asked a
> few people, but nobody knows about such an option.
> Does anybody here knows the SQL Server counterpart of "insert on
> existing skip/update"? If this doesn't exist, this is a minus for
> MS ;).
I'm afraid that you will have to chalk up one minus for MS SQL Server.
You will have to do:
UPDATE ...
INSERT ...
SELECT ...
WHERE NOT EXISTS (....)
--
Erland Sommarskog, SQL Server MVP, esquel@sommarskog.se
Books Online for SQL Server 2005 at
http://www.microsoft.com/technet/prodtechnol/sql/2005/downloads/books.mspx
Books Online for SQL Server 2000 at
http://www.microsoft.com/sql/prodinfo/previousversions/books.mspx
[Back to original message]
|