Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3393550
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T04:03:50+00:00 2026-05-18T04:03:50+00:00

I have a very large SELECT stored procedure that has multiple return columns and

  • 0

I have a very large SELECT stored procedure that has multiple return columns and multiple INNER JOINS and LEFT JOINS. I also have a table function with 10 columns and the result set of the table function is based of a user ID.

My question is, how do I incorporate the table function into the main SELECT stored procedure and be able to return the columns from the table function based on the user ID.

MAIN STORED PROCEDURE:

SELECT     
      dbo.WebPersonalInfo.UserID, 
      dbo.WebPersonalInfo.FirstName, 
      dbo.WebPersonalInfo.MiddleInitial, 
      dbo.WebPersonalInfo.LastName,
      dbo.WebProgramParticipants.ParticipantID, 
      dbo.WebProgramParticipants.ProgramCode, 
FROM  dbo.WebProgramParticipants INNER JOIN
      dbo.WebPersonalInfo ON dbo.WebProgramParticipants.UserID = dbo.WebPersonalInfo.UserID 
WHERE     (dbo.WebProgramParticipants.ProgramCode = @programcode) 
ORDER BY dbo.WebPersonalInfo.LastName, dbo.WebPersonalInfo.FirstName

TABLE FUNCTION:

SELECT 
        ST1.SKILL_SET_ID AS SET1, SS1.SET_NAME AS NAME1, ST1.SKILL_SET_RATING AS R1,
        ST2.SKILL_SET_ID AS SET2, SS2.SET_NAME AS NAME2, ST2.SKILL_SET_RATING AS R2,
        ST3.SKILL_SET_ID AS SET3, SS3.SET_NAME AS NAME3, ST3.SKILL_SET_RATING AS R3,
        ST4.SKILL_SET_ID AS SET4, SS4.SET_NAME AS NAME4, ST4.SKILL_SET_RATING AS R4,
        ST5.SKILL_SET_ID AS SET5, ST5.SKILL_SET_OPTIONAL AS NAME5, ST5.SKILL_SET_RATING AS R5,
        ST6.SKILL_SET_ID AS SET6, ST6.SKILL_SET_OPTIONAL AS NAME6, ST6.SKILL_SET_RATING AS R6,
        ST7.SKILL_SET_ID AS SET7, ST7.SKILL_SET_OPTIONAL AS NAME7, ST7.SKILL_SET_RATING AS R7,
        CM.COMMENTS
    FROM IPAM_RIPS_SKILL_SET_PARTICIPANT_RATING_HDR HT
    LEFT JOIN IPAM_RIPS_SKILL_SET_PARTICIPANT_RATING_DTL ST1
        ON HT.ID = ST1.HDR_ID and st1.SKILL_SET_ID = 1
    INNER JOIN IPAM_RIPS_SKILL_SETS SS1
        ON ST1.SKILL_SET_ID = SS1.ID
    LEFT JOIN IPAM_RIPS_SKILL_SET_PARTICIPANT_RATING_DTL ST2
        ON HT.ID = ST2.HDR_ID and st2.SKILL_SET_ID = 2
    INNER JOIN IPAM_RIPS_SKILL_SETS SS2
        ON ST2.SKILL_SET_ID = SS2.ID
    LEFT JOIN IPAM_RIPS_SKILL_SET_PARTICIPANT_RATING_DTL ST3
        ON HT.ID = ST3.HDR_ID and st3.SKILL_SET_ID = 3
    INNER JOIN IPAM_RIPS_SKILL_SETS SS3
        ON ST3.SKILL_SET_ID = SS3.ID
    LEFT JOIN IPAM_RIPS_SKILL_SET_PARTICIPANT_RATING_DTL ST4
        ON HT.ID = ST4.HDR_ID and st4.SKILL_SET_ID = 4
    INNER JOIN IPAM_RIPS_SKILL_SETS SS4
        ON ST4.SKILL_SET_ID = SS4.ID
    LEFT JOIN IPAM_RIPS_SKILL_SET_PARTICIPANT_RATING_DTL ST5
        ON HT.ID = ST5.HDR_ID and st5.SKILL_SET_ID = 5
    INNER JOIN IPAM_RIPS_SKILL_SETS SS5
        ON ST5.SKILL_SET_ID = SS5.ID
    LEFT JOIN IPAM_RIPS_SKILL_SET_PARTICIPANT_RATING_DTL ST6
        ON HT.ID = ST6.HDR_ID and st6.SKILL_SET_ID = 10
    INNER JOIN IPAM_RIPS_SKILL_SETS SS6
        ON ST6.SKILL_SET_ID = SS6.ID
    LEFT JOIN IPAM_RIPS_SKILL_SET_PARTICIPANT_RATING_DTL ST7
        ON HT.ID = ST7.HDR_ID and st7.SKILL_SET_ID = 11
    INNER JOIN IPAM_RIPS_SKILL_SETS SS7
        ON ST7.SKILL_SET_ID = SS7.ID
    INNER JOIN IPAM_RIPS_SKILL_SET_PARTICIPANT_RATING_COMMENTS CM
        ON HT.ID = CM.HDR_ID
    WHERE HT.PARTICIPANT_ID = @PARTICIPANT_ID
    GROUP BY PARTICIPANT_ID, ST1.SKILL_SET_ID, SS1.SET_NAME, ST1.SKILL_SET_RATING, ST2.SKILL_SET_ID, SS2.SET_NAME, ST2.SKILL_SET_RATING, ST3.SKILL_SET_ID, SS3.SET_NAME, ST3.SKILL_SET_RATING, ST4.SKILL_SET_ID, SS4.SET_NAME, ST4.SKILL_SET_RATING, ST5.SKILL_SET_ID, ST5.SKILL_SET_OPTIONAL, ST5.SKILL_SET_RATING, ST6.SKILL_SET_ID, ST6.SKILL_SET_OPTIONAL, ST6.SKILL_SET_RATING, ST7.SKILL_SET_ID, ST7.SKILL_SET_OPTIONAL, ST7.SKILL_SET_RATING, CM.COMMENTS
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-18T04:03:50+00:00Added an answer on May 18, 2026 at 4:03 am

    Andomar’s answer is correct, but… have you considered just using a VIEW instead? Much simpler, and almost certainly faster.

    Take the function, remove the WHERE clause, and add PARTICIPANT_ID to the SELECT list; that’s your view. You then JOIN to it just as if it were a table, on Participant_ID.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a very large (~8 gb) text file that has very long lines.
I have a very large db that I am working with, and I need
I have a very large table (374870 rows) and when I run the following
I'm currently in the middle of a reasonably large question / answer based application
I have a question about testing the queries in a transaction. I've been using
My website stores several million entities. Visitors search for entities by typing words contained
I am currently researching the best methods to integrate i18n into projects. There's several
I am building my wife a Contacts Manager program as a fun exercise in
i m not sure how to describe this as i m new with all
I am getting this error when I try to query the database and write

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.