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
637 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

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Join & Write a Comment

Introduction This article will provide a solution for an error that might occur installing a new SQL 2005 64-bit cluster. This article will assume that you are fully prepared to complete the installation and describes the error as it occurred durin…
Introduction: When running hybrid database environments, you often need to query some data from a remote db of any type, while being connected to your MS SQL Server database. Problems start when you try to combine that with some "user input" pass…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…
This video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …

760 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

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now