Click here to Skip to main content
15,888,286 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Hi, Good Evening All,Here I am having a problem with stored procedure, that is, I created a stored procedure ,in that I am selecting values from multiple tables,that values I have to return from stored procedure to my code page.This is my code
SQL
SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO


alter PROCEDURE [dbo].[GetUserwithPermission] 
	(
	@userId uniqueidentifier,
	@policyid uniqueidentifier,
	@objectId uniqueidentifier,
	@ITID bigint
	)
AS
BEGIN
	
	SET NOCOUNT ON;
	declare @ubaAttributeValue varchar(250) 
	declare @ubaAttributeId uniqueidentifier
	declare @policyname varchar(250) 
	declare @permissionname varchar(250) 

   
      select @policyname=(select policyname from policy where policyid=@policyid )
      select @ubaattributeid=(select ubaattributeid from usrbyattributes where ubauserid=@userId)
      select @ubaAttributeValue=(select ubaattributevalue from usrbyattributes where ubaattributeid=@ubaattributeid and ubauserid=@userId)
      select @permissionname=(select permissionname from  WAAD_PermissionByGroup where wpbggroupid=@objectId)
  
   
END

GO


Here I am getting the error like this:
XML
Subquery returned more than 1 value. This is not permitted when the subquery follows =, !=, <, <= , >, >= or when the subquery is used as an expression.
Posted
Updated 31-Jan-14 0:47am
v2

1 solution

Try this

SQL
select @policyname=(select top 1 policyname from policy where policyid=@policyid )
     select @ubaattributeid=(select top 1 ubaattributeid from usrbyattributes where ubauserid=@userId)
     select @ubaAttributeValue=(select top 1 ubaattributevalue from usrbyattributes where ubaattributeid=@ubaattributeid and ubauserid=@userId)
     select @permissionname=(select top 1 permissionname from  WAAD_PermissionByGroup where wpbggroupid=@objectId)
 
Share this answer
 

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