Note that there are some explanatory texts on larger screens.

plurals
  1. POStored procedure output value to variable
    primarykey
    data
    text
    <p>I'm new to stored procedure world.</p> <p>We have existing system with existing stored procedure, which checks username and url path. Stored procedure will check whether user details exist. If exists return value groupname where user name belong to.</p> <p>All I want is writing asp.net c# code for this stored procedure. Passing user details and path and returning stored procedure return value into string variable.</p> <p>Below link for SQL Server execute stored procedure</p> <p><a href="http://www.natboxservices.com/helmshore/img/pic.jpg" rel="nofollow">http://www.natboxservices.com/helmshore/img/pic.jpg</a></p> <p>Below link for SQL Server output value look like</p> <p><a href="http://www.natboxservices.com/helmshore/img/2012-07-03%2009.35.13.jpg" rel="nofollow">http://www.natboxservices.com/helmshore/img/2012-07-03%2009.35.13.jpg</a></p> <p>note that above picture groupname is empty cause i executed stored procedure with wrong input and there is no groupname exists for that data in sqlserver. if exists it will return a value for group name such as "administrator " or "Manager"</p> <p>my question is "if data exists and return group name i want to pass that value into string variable" for that assigning the parameter and pass return value into string variable</p> <p>This is my storedprocedure</p> <pre><code>USE [IRC_siteadmin] GO /****** Object: StoredProcedure [dbo].[sp_intranet_GetSecurity] Script Date: 07/03/2012 10:05:35 ******/ SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO CREATE PROCEDURE [dbo].[sp_intranet_GetSecurity] @username VARCHAR(50), @path VARCHAR(200), @errorID INT OUTPUT AS BEGIN SELECT G.name as groupname FROM tbl_site_link L WITH(NOLOCK) INNER JOIN tbl_site_link_group LG WITH(NOLOCK) ON L.link_id = LG.link_id INNER JOIN tbl_site_group G WITH(NOLOCK) ON LG.group_id = G.group_id INNER JOIN ( SELECT group_id FROM tbl_site_user U WITH(NOLOCK) INNER JOIN tbl_site_user_group UG WITH(NOLOCK) ON U.user_id = UG.user_id WHERE [name] = @Username ) U ON G.group_id = U.group_id WHERE L.url LIKE '%'+@path+'%' AND (U.group_id IS NOT NULL) UNION SELECT 'Uber' as groupname FROM tbl_site_link L WITH(NOLOCK) INNER JOIN tbl_site_link_group LG WITH(NOLOCK) ON L.link_id = LG.link_id CROSS JOIN ( SELECT group_id FROM tbl_site_user U WITH(NOLOCK) INNER JOIN tbl_site_user_group UG WITH(NOLOCK) ON U.user_id = UG.user_id WHERE [name] = @Username AND group_id = 1 ) U WHERE L.url LIKE '%'+@path+'%' AND (U.group_id IS NOT NULL) END </code></pre> <p>any help appreciated</p> <p>thanks</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload