Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
How will I compare the old value with new while updating
Message
 
 
À
22/05/2005 02:41:23
Information générale
Forum:
Visual FoxPro
Catégorie:
Base de données, Tables, Vues, Index et syntaxe SQL
Versions des environnements
Visual FoxPro:
VFP 8 SP1
OS:
Windows 2000 SP4
Network:
Windows 2000 Server
Database:
MS SQL Server
Divers
Thread ID:
01016451
Message ID:
01016577
Vues:
13
In general
UPDATE mytable
    SET myfield1 = @NewValue1,
    SET myfield2 = @NewValue2,
    SET myfield3 = @NewValue3
  WHERE < whetever conditions >
However in this case you cannot base update on changes in any particular column anymore. You can update ALL columns either when any of the columns changed or all of them changed. I doubt you would want to use the last condition though.
-- Any column changes
  WHERE < whetever conditions >
    AND ( myfield1 <> @NewValue1
      OR myfield2 <> @NewValue2
      OR myfield3 <> @NewValue3)
-- All column changes
  WHERE < whetever conditions >
    AND  myfield1 <> @NewValue1
    AND myfield2 <> @NewValue2
    AND myfield3 <> @NewValue3
>sir, I have one more qustions, if this table contains three fileds then how can i update
>iduvidualy in a single statement.
>
>UPDATE mytable
> SET myfield = @NewValue
> WHERE < whetever conditions >
> AND myfield <> @NewValue
>>
>>While updating data in the server, i want to skip the field if and only if the new value
>>and old the values are same. Othewise i want to update the field with new value.
>>how will i write Sql Statement for this.
>>
>
--sb--
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform