Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
SQL Select and set to variable
Message
 
 
To
06/03/2015 15:56:03
General information
Forum:
Microsoft SQL Server
Category:
SQL syntax
Environment versions
SQL Server:
SQL Server 2014
Application:
Web
Miscellaneous
Thread ID:
01616353
Message ID:
01616372
Views:
45
Can you provide more details?

>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
--sb--
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform