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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T03:48:08+00:00 2026-06-05T03:48:08+00:00

I am developing a solution for statistic data for a customer and now i

  • 0

I am developing a solution for statistic data for a customer and now i need to select some rows from a table (sell data) by using dynamic condition that come from another table (filled by the customer and it can change daily).

Also i need to use a cursor to perform more calculation and other stuff so this is the scenario:

DECLARE cRiga CURSOR LOCAL FAST_FORWARD FOR
    -- here i will put the SELECT ...
OPEN cRiga
    FETCH NEXT FROM cRiga INTO @field1, @field2, @field3, ...
    WHILE @@FETCH_STATUS = 0
    BEGIN
        -- do some stuff here ...
        FETCH NEXT FROM cRiga INTO @field1, @field2, @field3, ...
    END
CLOSE cRiga
DEALLOCATE cRiga

this is the Condition Table where i can find the dynamic condition (see the colum Completa = 0)

IDIncentive CdMarca CdSettore CdGruppo Completa
----------- ------- --------- -------- -----------
1           COES    NULL      NULL     1
1           DELONG  10        0024     0  <
1           RHOSS   NULL      NULL     1
1           SILE    10        0012     0  <
1           SILE    11        0025     0  <
1           THERMI  NULL      NULL     1
....... more rows ...

To be more clear i try to explode the SQL required in many queries as:

Select Field1, ... from SELLDATA 
where IDIncentive=1 and CdMarca='DELONG' and CdSettore=10 and CdGruppo='0024'
UNION ALL
Select Field1, ... from SELLDATA 
where IDIncentive=1 and CdMarca='SILE' and CdSettore=10 and CdGruppo='0012'
UNION ALL
Select Field1, ... from SELLDATA 
where IDIncentive=1 and CdMarca='SILE' and CdSettore=11 and CdGruppo='0025'

As u can imagine i cant do that because the conditions change daily by the customer so my question is:

How i can create a select that have all the conditions (as my example above) to use in the cursor ? There are a way ?

Thanks for who can help me and please advise if need more information to make more clear this question

  • 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-06-05T03:48:09+00:00Added an answer on June 5, 2026 at 3:48 am

    You can use your already existing ConditionTable table to filter SELLDATA by means of join: no cursor, no union all.

    Select Field1, ... 
      from SELLDATA 
     inner join ConditionTable
        ON SELLDATA.IDIncentive=ConditionTable.IDIncentive 
       and SELLDATA.CdMarca=ConditionTable.CdMarca
       and SELLDATA.CdSettore=ConditionTable.CdSettore
       and SELLDATA.CdGruppo=ConditionTable.CdGruppo
     where ConditionTable.Completa = 0
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm developing a Web application. I need to display some decimal data correctly so
I am developing a solution for transfering data from android phone to the server
I'm developing a C# solution where I use files as external resources. I need
I am developing an custom API for a web solution and I am using
I'm developing a solution for SharePoint 2007, and I'm using SPSecurity.RunWithElevatedPrivileges a lot, passing
Currently i am working on developing one Warehouse solution from scratch, i am planning
We are developing a Sharepoint solution using Visual Studio 2008 Extensions for SharePoint Svcs
We are developing a document management solution with Sharepoint 2007 and I'm having some
I'm developing WinForms application using VS2010. I have about 15 projects in the solution.
I am developing a solution which will utilize msmq to transmit data between two

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.