Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
SQL Select and set to variable
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:
01616353
Message ID:
01616370
Vues:
35
I am working on a SQL select and update that requires it to "keep track" of total number/value that has been processed.
Perhaps there is a way to do it without a variable.

>I have to ask, why?
>
>>When I try the following test, I get error (below the expression)
>>
>>Declare MyVar decimal (12,2)
>>Select Field1, @MyVar = num_field from MyTable
>>
>>
>>that "A SELECT statement that assigns a value to a variable must not be combined with data-retrieval operations."
>>
>>Is there a way to still retrieve data and set a value to a variable?
>>
>>TIA
"The creative process is nothing but a series of crises." Isaac Bashevis Singer
"My experience is that as soon as people are old enough to know better, they don't know anything at all." Oscar Wilde
"If a nation values anything more than freedom, it will lose its freedom; and the irony of it is that if it is comfort or money that it values more, it will lose that too." W.Somerset Maugham
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform