Solved

A SELECT statement that assigns a value to a variable must not be combined with data-retrieval operations.

Posted on 2009-04-06
3
660 Views
Last Modified: 2012-05-06
Hi

Why the following SP make the error:

A SELECT statement that assigns a value to a variable must not be combined with data-retrieval operations.


@id int
AS
BEGIN
Declare @clientid int
Declare @currencyid int
select @clientid = clientid, @currencyid = currencyid, amount from transactions where id = @id

Open in new window

0
Comment
Question by:techques
  • 2
3 Comments
 
LVL 26

Expert Comment

by:Chris Luttrell
ID: 24083950
because "@clientid = clientid, @currencyid = currencyid" in the select in assinging values to those variables and "amount" is trying to retrieve the amount value.  You can not do both in one statement.
0
 

Author Comment

by:techques
ID: 24083989
Does the following work?
Declare @clientid int
Declare @currencyid int
Declare @amount decimal (18,2)
select @clientid = clientid, @currencyid = currencyid, @amount = amount from transactions where id = @id

Open in new window

0
 
LVL 26

Accepted Solution

by:
Chris Luttrell earned 50 total points
ID: 24084076
Yes it should run and give you the values in your 3 variables.
0

Featured Post

Backup Your Microsoft Windows Server®

Backup all your Microsoft Windows Server – on-premises, in remote locations, in private and hybrid clouds. Your entire Windows Server will be backed up in one easy step with patented, block-level disk imaging. We achieve RTOs (recovery time objectives) as low as 15 seconds.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In this article I will describe the Backup & Restore method as one possible migration process and I will add the extra tasks needed for an upgrade when and where is applied so it will cover all.
In this article I will describe the Copy Database Wizard method as one possible migration process and I will add the extra tasks needed for an upgrade when and where is applied so it will cover all.
Windows 10 is mostly good. However the one thing that annoys me is how many clicks you have to do to dial a VPN connection. You have to go to settings from the start menu, (2 clicks), Network and Internet (1 click), Click VPN (another click) then fi…
Two types of users will appreciate AOMEI Backupper Pro: 1 - Those with PCIe drives (and haven't found cloning software that works on them). 2 - Those who want a fast clone of their boot drive (no re-boots needed) and it can clone your drive wh…

770 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question