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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T05:15:07+00:00 2026-06-01T05:15:07+00:00

I have a table the fields are Id1 , ID2 , Points1 , Points2

  • 0

I have a table the fields are Id1, ID2, Points1, Points2. I have another table that has the columns Id1, Id2, Address1, address2, city 1, city2, state1, state2. I have to update the pointsA and PointsB column based on how many of the columns in the second table are filled meaning they dont have null. Ex

Table 1

ID1  ID2   Points 1 Points2
1     2     2         0

Table 2

ID1  ID2 Address1 address2 city 1 city2 state1 state2.
1    2    a1       null     null   null  s1     null

How can I achieve this in sql server 2008?

Thanks

  • 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-01T05:15:09+00:00Added an answer on June 1, 2026 at 5:15 am
    UPDATE t1
    SET 
        Points1 = t2.Points1, 
        Points2 = t2.Points2
    FROM
        Table1 t1 JOIN (
        SELECT
            ID1,
            ID2,
            CASE WHEN Address1 IS NULL THEN 0 ELSE 1 END +
            CASE WHEN City1 IS NULL THEN 0 ELSE 1 END +
            CASE WHEN State1 IS NULL THEN 0 ELSE 1 END AS Points1,
            CASE WHEN Address2 IS NULL THEN 0 ELSE 1 END +
            CASE WHEN City2 IS NULL THEN 0 ELSE 1 END +
            CASE WHEN State2 IS NULL THEN 0 ELSE 1 END AS Points2,
        FROM Table2
    ) t2 ON t1.ID1 = t2.ID1 AND t1.ID2 = t2.ID2
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a table of reports that has these relevant fields: user_id (int 11)
I have table with some fields that the value will be 1 0. This
I have a table with three fields, User , City and Country , where
I have a legacy object model that has content objects and a table designed
I have one table users with 2 fields : id , name and another
I have my Table structure like this :: ATT_Table : Fields - Act_ID, Assigned_To_ID,
I have Access table with fields, in which there is some data and path
I have table consisting of these fields: id | date_from | date_to | price
I have table consisting of these fields: id | date_from | date_to | price
I have a table with three fields, FirstName, LastName and Email. Here's some dummy

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.