Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

passing parameters to function when multiple input 1

Status
Not open for further replies.

godfrey62

Programmer
Jun 22, 2001
14
US
Everyone's gone for the day and I need help. Working in Management Studio and I've been given a function to run that needs two parameters, an ID# and a date. I have a table with the ID#s and dates to be used, but having trouble figuring how to pass info to function and returning four fields into a table.

The function is in one database and my source table is in another.

EXEC PPP.UTIL.CALC_DOC_ELIG_SEGS_V2 '01234567','7/13/2009'

where PPP is the database the function resides in.

was attemtping this


SELECT
PPP.UTIL.CALC_DOC_ELIG_SEGS_V2 [ID#], [UseDate]

,UseDate -- to have output of date entered

INTO #TEST_A
FROM MINE.InformationTable

The function returns four fields: ID#, Row#, StartDate, EndDate

Thanks in advance for any direction you can provide.

 
If this is a table-valued function, then

select myTable.* cross apply MyOtherDatabase.dbo.myFunc(myTable.Field1, myTable.Field2)

If this is a scalar function, then

select myTable.*, MyOtherDatabase.dbo.myFunc(myTable.Field1, myTable.Field2) as NewField from myTable
 
Thank you for options. And now I'm gonna look stupid - it appears the process is a stored procedure and not a function at all.

I tried both methods offered but neither worked - presuming because it's a stored procedure and not a "function" after all.

Anyone offer anything with this new insight?
 
If it is a stored procedure, then look into INSERT INTO syntax.

You need to create a tepm table and use INSERT into #temp execute(MySP...)

Though, if you need it for every record in a table, then I believe the only option is to run it in a loop.
 
Thank you very much - I have some code for running processes in a loop, which is likely going to be the answer. I appreciate your time and expertise !!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top