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

  • Home
  • SEARCH
  • 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 806851
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T00:18:37+00:00 2026-05-15T00:18:37+00:00

EDIT Sorry for the half post :( It seems I cannot use a column

  • 0

EDIT
Sorry for the half post 🙁

It seems I cannot use a column from the parent query in a sub query.
How can I refactor this query to get what I need?

dbo.func_getRelatedAcnts returns a table of related accounts (all children from a given account). It goes up to the top level parent account of a given account and then selects all child accounts from there. This gives me a table of all the parent, sibling, and child account ids.

Events has a foreign key to an Account and Profiles has a foreign key to accounts.

Registrations have a foreign profile key and event key. There can be multiple regs per profile. I need to find all the regs that are associated with profiles that are in accounts that are not in any way related hierarchically to the event the registration is in.

The problem is that I want to use the profile account key of profile related to the reg in the parent query to dynamically grab the table in the subquery.

SELECT COUNT(r.reg_id)  
FROM registrations r 
JOIN profiles p ON (r.reg_frn_pro_id = p.pro_id)  
JOIN events e ON (r.reg_frn_evt_id = e.evt_id)  
WHERE evt_frn_acnt_id NOT IN 
      (SELECT * FROM dbo.func_getRelatedAcnts(p.pro_frn_acnt_id))  

My error:
pro_frn_acnt_id is not a recognized table hints option. If it is intended as a parameter to a table-valued function, ensure that your database compatibility mode is set to 90.

  • 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-15T00:18:38+00:00Added an answer on May 15, 2026 at 12:18 am

    This works for me:

    CREATE FUNCTION fn_tvf(@input INT)
    RETURNS TABLE
    AS
            RETURN
            (
            SELECT  @input AS id
            UNION ALL
            SELECT  @input + 1
            )
    
    GO
    
    ;WITH    q AS
            (
            SELECT  1 AS id
            ),
            t AS
            (
            SELECT  3 AS id
            )
    SELECT  *
    FROM    q
    CROSS JOIN
            t
    WHERE   t.id NOT IN (SELECT  * FROM fn_tvf(q.id))
    

    What is exact error message you get?

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

Sidebar

Ask A Question

Stats

  • Questions 407k
  • Answers 407k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer When you minimize a program under Windows, it does the… May 15, 2026 at 6:35 am
  • Editorial Team
    Editorial Team added an answer Ehm? var testVariable = 10; var oldVar = testVariable; ...… May 15, 2026 at 6:34 am
  • Editorial Team
    Editorial Team added an answer Yes, autonomous transactions can be dangerous. Consider the situation where… May 15, 2026 at 6:34 am

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.