Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Update if exist and insert if it doesn't
Message
De
11/08/2001 16:20:07
 
 
À
Tous
Information générale
Forum:
Microsoft SQL Server
Catégorie:
Syntaxe SQL
Titre:
Update if exist and insert if it doesn't
Divers
Thread ID:
00542663
Message ID:
00542663
Vues:
39
Is there a way to do this in one instruction :

update mytable set datafield=datavalue where keyfield=keyvalue
if @@rowcount=0
insert into mytable (keyfield, datafield) values (keyvalue, datavalue)

In other words : for a given key update a row and if it doesn't exist insert a row with that key/data
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform