Products

Solutions

Resources

Partners

Community

About

New Community Website

Ordinarily, you'd be at the right spot, but we've recently launched a brand new community website... For the community, by the community.

Yay... Take Me to the Community!

Welcome to the DNN Community Forums, your preferred source of online community support for all things related to DNN.
In order to participate you must be a registered DNNizen

HomeHomeDevelopment and...Development and...SQL and SQL Ser...SQL and SQL Ser...Update dnn_UserProfile: Update multiple rows based on multiple valuesUpdate dnn_UserProfile: Update multiple rows based on multiple values
Previous
 
Next
New Post
8/18/2011 4:12 PM
 
Lets say I have this:

    Declare @passRefID as int
    Declare @passTextA as varchar
    Deckare @oassTextB as varchar
    Declare @passPropertyA as int
    Declare @passPropertyB as int

   
    Set @oassTextA = 'Joe'
    Set @passTextB = 'Smith'
    Set @passPropertyA = 21
    Set @passPropertyB = 23

TSQL A:

    Set @passRefID = Select Ref_ID from TableA where ID = 10

The `Ref_ID` returns a value of 50

Now I want to use that value in another select statement which returns any amount of rows.
It looks like this

TSQL B:


    Select UserID from TableB where FK_RefID = @passRefID

So lets say it returns:

    UserID
    34
    56
    87

Now I want to create an update for `TableC` based on the `UserID` that return previously.

My TableC layout of records look like this from the userProfile table

ID, UserID, PropertyDefinitionID, PropertyValue
265,34,21,Bob
266,34,23,Barker
271,34,55,bb@abc.com
628,56,21,Jane
629,56,23,Adams
635,56,55,ja@abc.com
901,83,21,Tom
905,83,23,Thumb
910,83,55,tt@abc.com

I know I can use:

    Update TableC Set PropertyValue = @oassTextA Where UserID = 34 and PropertyDefinitionID = @passPropertyA
    Update TableC Set PropertyValue = @oassTextB Where UserID = 34 and PropertyDefinitionID = @passPropertyB
    Update TableC Set PropertyValue = @oassTextA Where UserID = 56 and PropertyDefinitionID = @passPropertyA
    Update TableC Set PropertyValue = @oassTextB Where UserID = 56 and PropertyDefinitionID = @passPropertyB
    Update TableC Set PropertyValue = @oassTextA Where UserID = 83 and PropertyDefinitionID = @passPropertyA
    Update TableC Set PropertyValue = @oassTextB Where UserID = 83 and PropertyDefinitionID = @passPropertyB

But my problem is that in TSQL B, those rows returned could differ. There could be 1 row or 100 rows returned and the TableC is constructed a bit different from the norm.

How can I create a dynamic `UPDATE` statement based on the amount of rows return using the unique USERIDs and the way the TableC uses the PropertyDefinitionID?

Thanks for your assistance.
 
Previous
 
Next
HomeHomeDevelopment and...Development and...SQL and SQL Ser...SQL and SQL Ser...Update dnn_UserProfile: Update multiple rows based on multiple valuesUpdate dnn_UserProfile: Update multiple rows based on multiple values


These Forums are dedicated to discussion of DNN Platform and Evoq Solutions.

For the benefit of the community and to protect the integrity of the ecosystem, please observe the following posting guidelines:

  1. No Advertising. This includes promotion of commercial and non-commercial products or services which are not directly related to DNN.
  2. No vendor trolling / poaching. If someone posts about a vendor issue, allow the vendor or other customers to respond. Any post that looks like trolling / poaching will be removed.
  3. Discussion or promotion of DNN Platform product releases under a different brand name are strictly prohibited.
  4. No Flaming or Trolling.
  5. No Profanity, Racism, or Prejudice.
  6. Site Moderators have the final word on approving / removing a thread or post or comment.
  7. English language posting only, please.
What is Liquid Content?
Find Out
What is Liquid Content?
Find Out
What is Liquid Content?
Find Out