Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
Author |
Topic |
Kickaboo
Starting Member
10 Posts |
Posted - 2008-02-29 : 14:05:01
|
Hi,This is probably the most basic of solutions, but I have spent the last 3 hours trying to work it out, and searching google!I am trying to call information from a stored procedure (B), from within another stored procedure (A). The select statement from Procedure A contains information to be passed to Procedure B, to get some information.This is the Procedure I have come up with so far, and I have included dbo.USERS_MEMBERSHIPSTATUS.STATUS(2, dbo.Members.EntryID) as part of the SELECT clause, in a vain attempt that this would work....but it dosn't!Anyone got any ideas of how to do this? Or even what it would be called so I can start making inteligent searches on google?USE [QP]GO/****** Object: StoredProcedure [dbo].[USERS_LIST] Script Date: 02/29/2008 18:24:16 ******/SET ANSI_NULLS ONGOSET QUOTED_IDENTIFIER ONGOALTER Procedure [dbo].[USERS_LIST] @STYPE Int, @UserID Int, @Username varchar(100), @Surname varchar(100), @DOB VarChar(40), @Location varchar(100), @Email Varchar(100), @Mobile varchar(100)AsSELECT TOP 100 PERCENT dbo.Members.EntryID, dbo.Members.EntryDate, dbo.Members.Username, dbo.Members.Forename, dbo.Members.Surname, dbo.Members.Gender, dbo.Members.DateofBirth, dbo.Members.LastAction, dbo.Members.AdminUser, dbo.ActiveMember_Mobile.Value AS Mobile, dbo.ActiveMember_Email.Value AS Email, dbo.ActiveMember_Location.Location1, dbo.ActiveMember_Location.Location2, dbo.ActiveMember_Location.Location3, dbo.ActiveMember_Location.Location4, dbo.F_AGE_IN_YEARS(dbo.members.dateofbirth, GetDate()) As Age, dbo.USERS_MEMBERSHIPSTATUS.STATUS(2, dbo.Members.EntryID)FROM dbo.Members INNER JOIN dbo.ActiveMember_Location ON dbo.Members.EntryID = dbo.ActiveMember_Location.UserID LEFT OUTER JOIN dbo.ActiveMember_Email ON dbo.Members.EntryID = dbo.ActiveMember_Email.UserID LEFT OUTER JOIN dbo.ActiveMember_Mobile ON dbo.Members.EntryID = dbo.ActiveMember_Mobile.UserIDWHERE @STYPE = '1' AND ((dbo.Members.EntryID = @UserID) or (dbo.Members.Username = @Username) or (dbo.Members.Surname = @surname) or (dbo.Members.DateofBirth = Convert(datetime, @DOB)) or (dbo.ActiveMember_Location.Location2 = @Location) or (dbo.ActiveMember_Location.Location3 = @Location) or (dbo.ActiveMember_Location.Location4 = @Location) or (dbo.ActiveMember_Email.value = @Email) or (dbo.ActiveMember_Mobile.value = @Mobile))ORDER BY dbo.Members.Username |
|
graz
Chief SQLTeam Crack Dealer
4149 Posts |
Posted - 2008-02-29 : 14:58:40
|
From what I see you need to use a scalar user-defined function and not a stored procedure. That will produce a single scalar value that you can use in your SELECT statement.=================================================Creating tomorrow's legacy systems today. One crisis at a time. |
 |
|
|
|
|
|
|