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 1042093
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T15:27:10+00:00 2026-05-16T15:27:10+00:00

ALTER PROCEDURE [dbo].[GetValues] @FieldName NVARCHAR(50), @FormName NVARCHAR(50), @PoolName NVARCHAR(50) AS SELECT FieldValue FROM [dbo].[Values]

  • 0
ALTER PROCEDURE [dbo].[GetValues]
@FieldName NVARCHAR(50),
@FormName NVARCHAR(50),
@PoolName NVARCHAR(50)

AS SELECT FieldValue FROM [dbo].[Values]

INNER JOIN [dbo].[Fields]
        ON [dbo].[Fields].FieldID = [dbo].[Values].FieldID

INNER JOIN [dbo].[FormFields]
        ON [dbo].[FormFields].FieldID = [dbo].[Fields].FieldID

INNER JOIN [dbo].[Forms]
        ON [dbo].[Forms].FormID = [dbo].[FormFields].FormID

INNER JOIN [dbo].[Pools]
        ON [dbo].[Pools].FormID = [dbo].[Forms].FormID

WHERE [dbo].[Fields].FieldName = @FieldName
  AND [dbo].[Forms].FormName = @FormName
  AND [dbo].[Pools].PoolName = @PoolName

I expected this code to filter the Values by Field, Form and Pool names. But it only filters by the Field name. What’s wrong?

Forms

FormID    FormName
96        FormA
98        FormB
97        FormC

Pools

PoolID    FormID    PoolName
29        96        PoolA1
31        98        PoolB1
30        97        PoolC1

Records

RecordID    PoolID
42          29
43          29
44          29
45          31
46          31
47          31

Values

FieldID    RecordID    FieldValue
101        42          Yellow
101        43          Yellow
101        44          Yellow
101        45          Pink
101        46          Pink
101        47          Pink
102        42          Smith
102        43          Jones
102        44          Fletchers
103        42          Fred
103        43          Bob
103        44          Marty

For example, if I filter with “Favorite color” (FieldID=101), “FormA” (FormID=96) and “PoolA1” (PoolID=29), it shows “Yellow,Yellow,Yellow,Pink,Pink,Pink” whereas it should be “Yellow,Yellow,Yellow”.

  • 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-16T15:27:11+00:00Added an answer on May 16, 2026 at 3:27 pm

    As I thought, the problem was in the stored procedure itself. Everything else was fine. The JOINs were incorrectly done and that’s the reason why I got erroneous results. Here’s the solution:

    ALTER PROCEDURE [dbo].[GetValues]
    @FieldName NVARCHAR(50),
    @FormName NVARCHAR(50),
    @PoolName NVARCHAR(50)
    
     AS SELECT FieldValue
          FROM [dbo].[Values]
    
    INNER JOIN [dbo].[Fields]
            ON [dbo].[Fields].FieldID = [dbo].[Values].FieldID
    
    INNER JOIN [dbo].[Records]
            ON [dbo].[Records].RecordID = [dbo].[Values].RecordID
    
    INNER JOIN [dbo].[Pools]
            ON [dbo].[Pools].PoolID = [dbo].[Records].PoolID
    
    INNER JOIN [dbo].[Forms]
            ON [dbo].[Forms].FormID = [dbo].[Pools].FormID
    
         WHERE [dbo].[Fields].FieldName = @FieldName
           AND [dbo].[Forms].FormName = @FormName
           AND [dbo].[Pools].PoolName = @PoolName
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have stored procedure: ALTER PROCEDURE [dbo].[k_ShoppingCart_DELETE] @cartGUID nvarchar AS DELETE FROM [dbo].[k_ShoppingCart] WHERE
From answers : ALTER PROCEDURE [dbo].[HardQ3] (@ID_User nvarchar(15), @ID_ListGroupParIzm Integer,@CIzmer Integer, @CPoint Integer, @UserExt
ALTER PROCEDURE dbo.Articles_InsertArticle @Article nvarchar(MAX), @UsersID uniqueidentifier AS INSERT INTO Articles (UsersID,Article,PageNumber) SELECT @UsersID,
ALTER PROCEDURE [dbo].[HO_GetListOfLeaguesPerLocation] AS BEGIN SELECT DISTINCT LeagueID, (EXEC dbo.HO_GetLeagueNumOfMatches LeagueID) FROM Games END
ALTER PROCEDURE [dbo].[GetTimeSheetsAttendance] @WhereClause varchar AS EXEC ('Select vwEmployeeList.ID,vwEmployeeList.Code, tbGNClient.FName + '' '' +
I've created the following stored procedure: ALTER PROCEDURE [dbo].[ExampleSP] ( @SearchText NVARCHAR(4000), @ID INT
ALTER PROCEDURE dbo.StoredProcedure8 @emp_code bigint, @co_id bigint, @p decimal(8,2) output AS SELECT @p =
I get error why? ALTER PROCEDURE dbo.verifGuids @value char(36), @message char(1)Output AS Begin select
Let say I have a simple Stored Procedure: ALTER PROCEDURE [dbo].[myProc] AS BEGIN SELECT
Possible Duplicate: TSQL Writing into a Temporary Table from Dynamic SQL ALTER PROCEDURE [dbo].[usp_ServicesStats1](@PERIOD

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.