all groups > sql server programming > july 2006 >
You're in the

sql server programming

group:

Questions Concerning Nested SP


Questions Concerning Nested SP ffrugone NO[at]SPAM gmail.com
7/24/2006 11:25:37 PM
sql server programming: OK, so here's the deal:

Using .NET 2.0 Membership DB for basic username, password, and other
login data. However, due to it's limitations and the headache that is
Profiles, I have the rest of my user information in another database on
the server, (that I call MyBigDB).

I wrote an SP within the Membership DB that gathers UserNames and
UserIDs for a given Role, (that I call GetUserInfoFromRole). I'm trying
to write an SP on MyBigDB that has a nested call to
GetUserInfoFromRole, and that will assign returned data to a table
variable, (if I can, since I read that table variables can't be used to
hold returned information from a nested SP, and that I'd have to use a
temporary table) so that I can join it with other tables from MyBigDB
before returning that data to the calling client.

The problems are two: 1) How do I make a call to GetUserInfoFromRole
(which is within the Membership DB) and then 2) Assign the returned
information to the table variable.

Here is SOME OF THE CODE from GetUserInfoFromRole:
******************************************************************************
ALTER PROCEDURE dbo.aspnet_GetUserInfoFromRole
@ApplicationName nvarchar(256),
@RoleName nvarchar(256),

AS

--Code omitted for brevity

SELECT u.UserName, u.UserID
FROM dbo.aspnet_Users u, dbo.aspnet_UsersInRoles ur
WHERE u.UserId = ur.UserId AND @RoleId = ur.RoleId AND
u.ApplicationId = @ApplicationId
ORDER BY u.UserName
RETURN(0)
END

******************************************************************************

Here is what I THINK I need to have:
******************************************************************************
ALTER PROCEDURE dbo.MyBigDB_DoWorkOnReturnedData
@ApplicationName nvarchar(256)
@RoleName nvarchar(256)
AS

BEGIN
DECLARE @infoHolder table (UserName nvarchar(256), UserID
uniqueidentifier)

USE ASPNETDB
INSERT INTO @infoHolder
EXEC dbo.aspnet_GetUserInfoFromRole (@ApplicationName,
@RoleName)

--Now: somehow stop using ASPNETDB and use MyBigDB. Maybe with:
USE MyBigDB

--Work with the @infoHolder data

END
******************************************************************************

Any evaluation or suggestions regarding the above would be greatly
appreciated. My hat is off to those that seek to help through this
forum.

ffrugone
Re: Questions Concerning Nested SP ffrugone NO[at]SPAM gmail.com
7/24/2006 11:46:18 PM
Thank you. I could not have asked for a reply so prompt and concise.
Re: Questions Concerning Nested SP Uri Dimant
7/25/2006 12:00:00 AM
Hi
[quoted text, click to view]

EXEC Membership.DBO.GetUserInfoFromRole

2) Assign the returned
[quoted text, click to view]

You can only EXECUTE into a temporary table

CREATE TABLE #Test (col.........)

INSERT INTO #Test EXEC Membership.DBO.GetUserInfoFromRole

SELECT * FROM #Test





[quoted text, click to view]

AddThis Social Bookmark Button