×
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Contact US

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Update script is changing the number of records for the values updated each time I run the query

Update script is changing the number of records for the values updated each time I run the query

Update script is changing the number of records for the values updated each time I run the query

(OP)


I have a a query result set in a temp table1 with 5 columns.
AcctNum, Location, GroupName, Count1, Count2. Columns Count1 and Count tow has 1s and nulls in it all the way through. I intend to sum these columns and group by Location, GroupName in a later step.

I need to update the GroupName column in table1 from another temp table2 where I have Distinct records of 3 columns. AcctNum, Location, GroupName2.

My update script is:

Update table1
Set GroupName = table2.GroupName2
From table1 Left Outer Join
table2 on table1.AcctNum = table2.AcctNum AND table1.Location = table2.Location

However, the number of occurrences of 1s in column1 and column2 keep changing for those records that were updated by the update script each time I run the script to validate the numbers. I am not sure what this keeps happening. Any Thoughts? see attached for sample tables and expected result without change to column1 and column2 values.

Thank you

RE: Update script is changing the number of records for the values updated each time I run the query

Try this:

CODE

Update table1
Set GroupName = (SELECT table2.GroupName2
                   From table2 
                  WHERE table1.AcctNum = table2.AcctNum 
                    AND table1.Location = table2.Location); 

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close