Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: ASP.NET C#4.0
this is the error:
 
Subquery returned more than 1 value. This is not permitted when the subquery follows =, !=, <, <= , >, >= or when the subquery is used as an expression.
 

My sql Query was:
 
USE [aspnetdb]
GO
 
/****** Object:  StoredProcedure [dbo].[sp_Permission]    Script Date: 04/29/2013 09:38:00 ******/
SET ANSI_NULLS ON
GO
 
SET QUOTED_IDENTIFIER ON
GO
 
Create procedure [dbo].[sp_Permission]
@RoleName nvarchar(50),
@SubMenu nvarchar(50)
as
begin
select Read_P,Write_P, Update_P, Delete_P from MenuMapping where RoleName=@RoleName and SubMenuId=(select SubMenuId from SubMenu where SubMenuLcation=@SubMenu)
end
GO
 

can anyone say possible solution for this... help me!!!
Posted 28-Apr-13 19:47pm
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

Please use this code.
 
use in clause instead of equal to.
 

 
USE [aspnetdb]
GO

/****** Object: StoredProcedure [dbo].[sp_Permission] Script Date: 04/29/2013 09:38:00 ******/
SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO

Create procedure [dbo].[sp_Permission]
@RoleName nvarchar(50),
@SubMenu nvarchar(50)
as
begin
select Read_P,Write_P, Update_P, Delete_P from MenuMapping where RoleName=@RoleName and SubMenuId in(select SubMenuId from SubMenu where SubMenuLcation=@SubMenu)
end
GO
  Permalink  
Comments
v surya dev at 29-Apr-13 1:06am
   
thank you... thank you so much... its running now....
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 2

<pre lang="xml">
select Read_P,Write_P, Update_P, Delete_P from MenuMapping where RoleName=@RoleName and SubMenuId in (select SubMenuId from SubMenu where SubMenuLcation=@SubMenu)
</pre>
 

there should be 'in' not '=' near to 'SubmenuID in (query)' reason your subquery is contain more than one row so db is confuse which row it has to take, after putting in it will consider all row to check and give you result for all matching result for your subquery
  Permalink  
Comments
v surya dev at 29-Apr-13 1:06am
   
thank you... thank you so much....

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

  Print Answers RSS
0 OriginalGriff 8,149
1 Sergey Alexandrovich Kryukov 7,287
2 DamithSL 5,614
3 Manas Bhardwaj 4,986
4 Maciej Los 4,910


Advertise | Privacy | Mobile
Web03 | 2.8.1411023.1 | Last Updated 29 Apr 2013
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100