Welcome to dbFreaks.com!
FAQFAQ    SearchSearch      ProfileProfile    Private MessagesPrivate Messages   Log inLog in

subquery returned more than one value

 
   Database Help (Home) -> Programming RSS
Next:  Looking-up certain records only  
Author Message
Mary Phelps

External


Since: Sep 01, 2010
Posts: 1



(Msg. 1) Posted: Wed Sep 01, 2010 4:47 am
Post subject: subquery returned more than one value
Archived from groups: microsoft>public>sqlserver>programming (more info?)

When I run this query:
update a set a.[UPC] = b.[IDSCE], a.[AltDescription] = b.[IDESC], a.
[Weight] = b.[IMNNWU],
from [ProductVariant] a inner join [IIMWEB] b on a.
[SKUSuffix]=b.[IPROD]

I receive an error:
The statement has been terminated.
Msg 512, Level 16, State 1, Procedure trig_NotificationProduct, Line
19
Subquery returned more than 1 value. This is not permitted when the
subquery follows =, !=, <, <= , >, >= or when the subquery is used as
an expression.

 >> Stay informed about: subquery returned more than one value 
Back to top
Login to vote
Scott Morris

External


Since: Aug 28, 2003
Posts: 86



(Msg. 2) Posted: Wed Sep 01, 2010 7:54 am
Post subject: Re: subquery returned more than one value [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

"Mary Phelps" wrote in message

> When I run this query:
> update a set a.[UPC] = b.[IDSCE], a.[AltDescription] = b.[IDESC], a.
> [Weight] = b.[IMNNWU],
> from [ProductVariant] a inner join [IIMWEB] b on a.
> [SKUSuffix]=b.[IPROD]
>
> I receive an error:
> The statement has been terminated.
> Msg 512, Level 16, State 1, Procedure trig_NotificationProduct, Line
> 19
> Subquery returned more than 1 value. This is not permitted when the
> subquery follows =, !=, <, <= , >, >= or when the subquery is used as
> an expression.

Pay special attention to the entire error message - in particular, the part
"Procedure trig_NotificationProduct". This name should give you a hint
about the source of the problem.

 >> Stay informed about: subquery returned more than one value 
Back to top
Login to vote
--CELKO--

External


Since: Jan 11, 2008
Posts: 1089



(Msg. 3) Posted: Fri Sep 03, 2010 7:56 pm
Post subject: Re: subquery returned more than one value [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

Google this newsgroup and read all the postings about why we do not
use the proprietary and dangerous UPDATE.. FROM.. syntax. You can use
the MERGE statement and be safe and be writing SQL instead of
dialect.

MERGE INTO A -- really awful name
USING IIMWEB AS B -- really bad alias
ON A.sku_suffix = B.iprod
WHEN MATCHED
THEN UPDATE
SET A.upc = B.idsce,
A.alt_something_description = B.idesc,
A.something_weight = B.imnnwu;

This will spot your cardinality errors. You will still get errors from
stinky data. And you should. FIX THE STINKY DATA!

I am sorry that you do not have consistent data element names in your
enterprise, but that is no reason to use aliases that make no sense or
table names like "A" in your code. Why would B tell someone
maintaining the code that we want IIMWEB?

It looks like some moron put the data types in the IIMWEB column
names. Storing a UPC as an integer is just plain wrong.
 >> Stay informed about: subquery returned more than one value 
Back to top
Login to vote
Bob McClellan

External


Since: Sep 03, 2010
Posts: 1



(Msg. 4) Posted: Fri Sep 03, 2010 7:59 pm
Post subject: Re: subquery returned more than one value [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

Mary,... I'm surprised you did not get a syntax error for the extra
comma....
When I run this query:
update a
set a.[UPC] = b.[IDSCE],
a.[AltDescription] = b.[IDESC],
a.[Weight] = b.[IMNNWU], --< extra comma

from [ProductVariant] a
inner join [IIMWEB] b on a.[SKUSuffix]=b.[IPROD]

>>I think this part: Subquery returned more than 1 value <<
is telling you that you have more than one match on a.[SKUSuffix]=b.[IPROD]
"Mary Phelps" wrote in message

> When I run this query:
> update a set a.[UPC] = b.[IDSCE], a.[AltDescription] = b.[IDESC], a.
> [Weight] = b.[IMNNWU],
> from [ProductVariant] a inner join [IIMWEB] b on a.
> [SKUSuffix]=b.[IPROD]
>
> I receive an error:
> The statement has been terminated.
> Msg 512, Level 16, State 1, Procedure trig_NotificationProduct, Line
> 19
> Subquery returned more than 1 value. This is not permitted when the
> subquery follows =, !=, <, <= , >, >= or when the subquery is used as
> an expression.
 >> Stay informed about: subquery returned more than one value 
Back to top
Login to vote
Display posts from previous:   
Related Topics:
Subquery returned more then one row - Hi, I've got a function that returns 1 row with a name from a customer. I call this function within a cursor when I'm looping a lot of activities. When I do this: set @CustomerName = (SELECT dbo.fn_CollectKlantName(@ActivityId,4214)) Then I get the...

NOT IN with a subquery - Hi there, A bit late to this post, but it's a problem I just had myself...and to stop anyone else scratching their head over this wondering what an earth is going on... I suspect you needed to check if you'd been playing with your ANSI_NULLS connection...

SubQuery Help - Hi Folks, I have the following query which works fine: SELECT o.lastname, r.parcel_no, l.landkey, s.saledate FROM REALPROP r JOIN OWNER o ON r.ownkey = o.ownkey JOIN LANDSUBS l ON r.realkey = l.realkey LEFT JOIN SALEINFO s ON r.realkey = s.realkey ORDE...

Update with Subquery - I have a table with columns Phone1 and Phone2. I want to update all Phone2 values with the value in Phone1 for all records where Phone1 is not null or Phone2 value is null. Begin Tran Update TABLE Set Phone2 = Phone1 Where Phone1 is not null and..

Help with Subquery and "Group By" - Hello everyone- I'm putting together a report that I really only want to pull data from one main table and join on lookup (lu) tables. I have my query in running condition but I just found out that I do not need to subquery a different..
   Database Help (Home) -> Programming All times are: Pacific Time (US & Canada)
Page 1 of 1

 
You can post new topics in this forum
You can reply to topics in this forum
You can edit your posts in this forum
You can delete your posts in this forum
You can vote in polls in this forum



[ Contact us | Terms of Service/Privacy Policy ]