Click here to Skip to main content
15,886,799 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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:

SQL
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

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
 
Share this answer
 
Comments
v surya dev 29-Apr-13 1:06am    
thank you... thank you so much... its running now....
XML
<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
 
Share this answer
 
Comments
v surya dev 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)



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