如何从存储过程中检索multipul值 [英] How to retrieve multipul values from stored procedure

查看:111
本文介绍了如何从存储过程中检索multipul值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

晚上好,这里我遇到了存储过程的问题,也就是说,我创建了一个存储过程,因为我从多个表中选择值,我必须从存储过程返回到我的代码page.This是我的代码

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

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:

Subquery returned more than 1 value. This is not permitted when the subquery follows =, !=, <, <= , >, >= or when the subquery is used as an expression.

推荐答案

试试这个



Try this

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)


这篇关于如何从存储过程中检索multipul值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆