Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Conditional update
Message
Information générale
Forum:
Microsoft SQL Server
Catégorie:
Syntaxe SQL
Titre:
Conditional update
Versions des environnements
SQL Server:
SQL Server 2005
Divers
Thread ID:
01187142
Message ID:
01187142
Vues:
83
I would like to write a "conditional" update statement, something like this:
UPDATE MyTable
SET    field1 = @field1,
       field2 = IIF(LEN(@field2)>0, @field2, field2),
       field3 = @field3
WHERE  field4 = @field4
To put this into words I want to update field2 only if the passed @field2 (nvarchar) parameter is non-empty string.

Is the above syntax the best syntax to use for this, or is there a better way?

Thanks,
Einar
Semper ubi sub ubi.
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform