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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T15:17:55+00:00 2026-06-15T15:17:55+00:00

I want to begin by stating I’m an SQL noob, so I’d appreciate any

  • 0

I want to begin by stating I’m an SQL noob, so I’d appreciate any suggestions or comments on my workflow and/or mindset when trying to solve this issue.

What I’m doing is gathering usage statistics about several applications, in several categories (not all categories necessarily apply to all applications), storing them in a database.

I’ve set up a few tables to do that, and then one table to link everything together that’s structured like so (from now on: Dtable):

(column name - details)  
UserID  - foreign key to another table which stores users data  
ApplicationID - foreign key to another table which stores applications data  
CategoryID - foreign key to another table which holds a list of different categories  
Value - the actual data

Each application gathers the data, then submits it to the database using a stored procedure. As the amount of data can be different based on actual usage (not always sending every category) and for each application, I was thinking of sending the data as a DataTable with a list of CategoryID and Value so I won’t have to call a procedure for every individual category (Ptable).

I need to update each record in Dtable to the correct value in Ptable according to CategoryID, but also filtered by UserID and ApplicationID. UserID and ApplicationID will be given as two other parameters to the Stored Procedure. Ptable only contains a list of CategoryID / Value records.

Now, I read about Cursors (for each record in the table parameter set the relevant data in the database table), but the consensus seems to be “Avoid at all costs”.

How would I go about updating the table, then, based on the varying records in Ptable?

P.S.
The tables are structured like so to keep agility and scalability in adding more categories/applications in the future. If there’s a better way to do it I’ll be happy to know.

  • 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-15T15:17:56+00:00Added an answer on June 15, 2026 at 3:17 pm

    I believe the update statement would look something like this, where @ApplicationID and @UserID are the stored proc’s other parameters:

    update Dtable
        set Dtable.Value = p.Value
        from Ptable p
        where Dtable.UserID = @UserID
            and Dtable.ApplicationID = @ApplicationID
            and Dtable.CategoryID = p.CategoryID;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to begin unit testing our application, because I believe that this is
Let me begin by stating that this is a question of aesthetics. I've solved
I want to begin using DBForge and migrations class thats built into CI but
I want to match expressions that begin with ${ and end with } in
I want to loop over the files that begin with '.' in directory x
I'm developing an application in WPF and I want to know how to begin
let me begin by stating that's i'm dreadful at math. i'm attempting to reposition
Let me begin by saying I do not want to disable or otherwise prevent
i have this problem: starting from an empty list (0 elements) i want check
Ok guys working on search suggestions using jQuery-UI AutoComplete with results from sql-sever 2008

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.