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.

 All Forums
 SQL Server 2005 Forums
 Transact-SQL (2005)
 Pass var from Stored Proc to Function

Author  Topic 

jbreslow
Starting Member

16 Posts

Posted - 2011-11-14 : 12:42:13
Hello,

How does one pass a value from a Stored Procedure to a Table-valued Function? I get the following error when I try to do so, "An insufficient number of arguments were supplied for the procedure or function dbo.f_AllReqX.". I am only passing one var to "f_ALLReqX()".

The SP:
SELECT top(1) @IDP=f_StudentCountAllPreceptorsReq_1.IDP,
@IDS=f_AllReqX_1.IDS,
@MatchCount=f_StudentCountAllPreceptorsReq_1.S_Count
FROM dbo.f_StudentCountAllPreceptorsReq() AS f_StudentCountAllPreceptorsReq_1
INNER JOIN dbo.f_AllReqX('no') AS f_AllReqX_1 ON f_StudentCountAllPreceptorsReq_1.IDP = f_AllReqX_1.IDP
INNER JOIN dbo.student as s on s.ids = f_AllReqX_1.IDS...

The Function:
ALTER FUNCTION [dbo].[f_AllReqX]
(
-- Add the parameters for the function here
@transp varchar(3)
)
RETURNS TABLE
AS
RETURN
(
SELECT f_DaysReqX_1.IDP, f_DaysReqX_1.IDS, f_DaysReqX_1.Tues, f_DaysReqX_1.Wed, f_DaysReqX_1.Thurs, f_TrackReqX_1.Track, f_TrackReqX_1.s_track,
f_FemReqX_1.Gender_Pref, f_FemReqX_1.gender, f_SpanishReqX_1.Spanish, f_SpanishReqX_1.language_spanish, f_TransportationReqX_1.transportation, f_TransportationReqX_1.officeZip
FROM dbo.f_DaysReqX() AS f_DaysReqX_1
INNER JOIN dbo.f_TransportationReqX(@transp) AS f_TransportationReqX_1 ON f_DaysReqX_1.IDP = f_TransportationReqX_1.IDP AND f_DaysReqX_1.IDS = f_TransportationReqX_1.IDS...)

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2011-11-14 : 13:17:38
you cant call a procedure like this in inner join. if you need to do it at all, you need to use it like 2nd method below

http://sqlblogcasts.com/blogs/madhivanan/archive/2007/11/26/select-columns-from-exec-procedure-name-is-this-possible.aspx

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page
   

- Advertisement -