Click here to Skip to main content
15,921,606 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Dear all i am executing stored procedure . at the time i am receiving the error :
XML
Subquery returned more than 1 value. This is not permitted when the subquery follows =, !=, <, <= , >, >= or when the subquery is used as an expression.
Subquery returned more than 1 value. This is not permitted when the subquery follows =, !=, <, <= , >, >= or when the subquery is used as an expression.
The statement has been terminated.
The statement has been terminated.

below is my coding please help me where i did error:
SQL
alter PROCEDURE [dbo].[Buson_CopySlabItems]
 -- Add the parameters for the stored procedure here
 @GrpCode VARCHAR(8)
AS
BEGIN

 DELETE FROM BZ_IAB3 WHERE BZ_IAB3.DocEntry=(select BZ_IAB2.DocEntry from BZ_IAB2 where BZ_IAB2.GrpCode=@GrpCode)

INSERT INTO BZ_IAB3(BZ_IAB3.DocEntry,BZ_IAB3.GrpCode,BZ_IAB3.ItemCode,BZ_IAB3.FrmSlab,BZ_IAB3.ToSlab,BZ_IAB3.Percentage)
select BZ_IAB2.DocEntry,OITM.ItemCode,BZ_IAB2.GrpCode,BZ_IAB2.FrmSlab,BZ_IAB2.ToSlab,BZ_IAB2.Percentage from OITM,BZ_IAB2
where BZ_IAB2.DocEntry=(select BZ_IAB2.DocEntry from BZ_IAB2 where BZ_IAB2.GrpCode=@GrpCode)
END
Posted
Comments
Richard C Bishop 18-Apr-13 16:55pm    
The exeception is self explanatory and it is probably taking place in the last Select statement in the code you have provided. Check this link for some ideas:

http://www.dbforums.com/microsoft-sql-server/978185-subquery-returned-more-than-1-value.html

1 solution

Hello,

The problem are here:
where BZ_IAB2.DocEntry=(select BZ_IAB2.DocEntry from BZ_IAB2 where BZ_IAB2.GrpCode=@GrpCode)


Your column
BZ_IAB2.DocEntry
can only be equal to one value, so, the query -
select BZ_IAB2.DocEntry from BZ_IAB2 where BZ_IAB2.GrpCode=@GrpCode
, are returning a list of records.

Cheers,
JAFC
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900