Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Conditional update syntax
Message
Information générale
Forum:
Microsoft SQL Server
Catégorie:
Syntaxe SQL
Versions des environnements
SQL Server:
SQL Server 2005
Divers
Thread ID:
01376414
Message ID:
01376415
Vues:
12
I think this should work. Please correct me if I am wrong
UPDATE [MyTable]
SET [Field1] = @Field1,
        [Field2] = @Field2,
        [Field3] = CASE WHEN [Field4] THEN [Field3] ELSE @Field3 END
>I think the answer to this is really simple but right now I cant see the forest for all the trees
>
>consider the update statement
>
>UPDATE [MyTable]
>SET [Field1] = @Field1,
>        [Field2] = @Field2,
>        [Field3] = if Field4 is true then [Field3] else @Field3
>
>
>In other words if Field4 is true (it is a bit field) then I do not want to update Field3, but if Field4 is false then I want to update Field3 with the passed parameter for Field3.
>
>Any help would be awesome
Semper ubi sub ubi.
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform