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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T16:39:30+00:00 2026-06-06T16:39:30+00:00

I have a table from which I query data to display resultset using stored

  • 0

I have a table from which I query data to display resultset using stored procedure. I also have a value to be given in the where condition that keeps changing for each and every cell and that parameter is not available in the table from which I have to query. As of now, I have hardcoded the for that particular parameter. My resultset should consist of 7 rows and 16 columns. Is there any optimistic way instead of hardcoding it ? Any help is appreciated.

Here is the temp table I ve hardcoded:

 create table #temp_financials(iden_val int identity(1,1) ,
     categ varchar(100),Retail_RDR varchar(100),Avg_Price_RDR varchar(100), 
             GPVR_RDR   varchar(100),
            L_RDR varchar(100),
       L_Avg_Price varchar(100),L_GPVL varchar(100),
    C_RDR varchar(100),C_Avg_Price varchar(100),C_GPVR varchar(100),
     C_Rgn_GPVR varchar(100),C_Nat_GPVR varchar(100),
       C_Lease_Penet varchar(100),C_Rgn_Penet varchar(100))

    insert into #temp_financials(categ,Retail_RDR ,Avg_Price_RDR , GPVR_RDR ,
      L_RDR ,L_Avg_Price ,L_GPVL ,
        C_RDR ,C_Avg_Price ,C_GPVR ,C_Rgn_GPVR ,C_Nat_GPVR ,
        C_Lease_Penet ,C_Rgn_Penet ) 
                 values('Ttl  Sum',             
         'B9720','B9996','B9776','B9722','B9997','B9791','B9733','B10003','B9806','B9806                 ','B9806','B9885','B9885'  )
         insert into #temp_financials(categ,Retail_RDR ,Avg_Price_RDR , GPVR_RDR ,
     L_RDR ,L_Avg_Price ,L_GPVL ,
          C_RDR ,C_Avg_Price ,C_GPVR ,C_Rgn_GPVR ,C_Nat_GPVR ,
         C_Lease_Penet ,C_Rgn_Penet ) 
                  values        ('B9870','B9773','4042A','B9998','B9788',
            'B9872','B2090','B9803','B9803','B9803','B10004','B10004')

Here is the table with which I ve to join:

     while(@loop_var<=@count_var)
        begin

       select                  t.categ,Retail_RDR=w1.CMValue,Avg_Price_RDR=w2.CMValue,
        GPVR_RDR=w3.CMValue,L_RDR=w4.CMValue,
    from westernunion  w1 join #temp_financials t on     
    w1.acct_no=t.retail_RDR left  outer join 
        westernunion  w2 on   w2.acct_no=t.avg_price_rdr 
        left outer join westernunion  w3 on  w3.acct_no=t.GPVR_RDR   
        left outer join westernunion w4 on w4.acct_no=t.L_RDR 
        where        t.iden_val=@loop_var
             set @loop_var=@loop_var+1
          end
  • 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-06T16:39:31+00:00Added an answer on June 6, 2026 at 4:39 pm

    Use dynamic SQL query:

    Declare @vQuery nvarchar(max),
            @vWhereClasue varchar(500)
    
    SET @vQuery = 'Select top 7 col1,col2 ....col16 from ... where ' + @vWhereClasue
    exec sp_executesql @vQuery
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i have a table array dynamically generated from a data query and stored in
I have to get data from Oracle Table in which I have one datefield
I have a data access page which gets all it's data from a query
I have created a passthrough query from an sql server database to display data
I have written an importer which copies data from a flat table into several
I have a join in a oracle query which looks like: FROM eiv.table1 eiv.table2
So I have this app which needs to query entities from the Azure Tables
I have the typical emp table from which i want to fetch the hierarchical
Let's say I have SELECT name FROM table which gives me something like foo
I have a table which is being dynamically populated from MySQL. The table has

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.