Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Update and Set in one statement?
Message
Information générale
Forum:
Microsoft SQL Server
Catégorie:
Syntaxe SQL
Versions des environnements
SQL Server:
SQL Server 2014
Application:
Web
Divers
Thread ID:
01611535
Message ID:
01611536
Vues:
58
>Hi,
>I would like to create a SQL Server command that would set a column to a value and at the same time set the value before the change.
>
>For example, say I have a table PartTable and I want to update the value of column INSTOCK to some value of the variable @StockQty but first set the value of this column to another variable, @StockQtyBeforeChange. This is the UPDATE part of the desired statement:
>
>
>update PartTable set instock = @StockQty where inv_code = @InvCode
>
>
>but I cannot see how to add the following into the statement above:
>
>
>select @StockQtyBeforeChange = instock from PartTable where inv_code = @InvCode
>
>
>Is it possible to do what I am thinking? TIA

I think it goes against my religion your use of variables in SQL...
update PartTable set @StockQtyBeforeChange = instock, instock = @StockQty  where inv_code = @InvCode
"The five senses obstruct or deform the apprehension of reality."
Jorge L. Borges?

"Premature optimization is the root of all evil in programming."
Donald Knuth, repeating C. A. R. Hoare

"To die for a religion is easier than to live it absolutely"
Jorge L. Borges
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform