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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T11:56:58+00:00 2026-05-12T11:56:58+00:00

So I have a table that looks like this: ProjectID TaskID Date 000 001

  • 0

So I have a table that looks like this:

ProjectID    TaskID     Date
000          001        10/28/09
000          002        12/1/09
000          003        02/24/10
001          001        04/14/10
001          002        07/5/10
001          003        02/24/11
002          001        06/07/10
002          002        07/7/10
002          003        09/13/12

Assume there are many projects and many tasks, but each project contains the same tasks. I want to copy dates in the following manner:

One project (000) has the master dates. I want to copy those dates for each task to several other projects (001, 002 in the example data).

So, if task 001 in project 000 has a date of 10/28/09, I want task 001 in other projects (I know their IDs) to have the same date.

If task 002 in project 001 has date 12/1/09, I want task 002 to have this date in each of the other projects as well.

Is there one query that can do this? I think there should be, but I can’t figure it out right now.

BTW I am using SqlServer 2005.

  • 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-05-12T11:56:59+00:00Added an answer on May 12, 2026 at 11:56 am
    UPDATE dbo.Projects
    SET Date = (SELECT Date FROM dbo.Projects p1
                WHERE p1.ProjectID = '000' AND p1.TaskID = dbo.Projects.TaskID)
    WHERE ProjectID IN ('P01', 'P02', 'P03', 'P04')
    AND TaskID IN ('001', '002', '003')
    

    Would that do it for you?

    So for TaskID = 001, this statement will

     SELECT Date FROM dbo.Projects WHERE ProjectID = '000' AND TaskID = '001'
    

    and then update each of the projects (P01-P04) and TaskID=001 to this date. That’s what you’re looking for, no??

    You can also use an OUTPUT clause to PROVE to you what is being updated:

    UPDATE dbo.Projects
    SET Date = (SELECT Date FROM dbo.Projects p1
                WHERE p1.ProjectID = '000' AND p1.TaskID = dbo.Projects.TaskID)
    OUTPUT inserted.ProjectID, inserted.TaskID, inserted.Date
    WHERE ProjectID IN ('P01', 'P02', 'P03', 'P04')
    AND TaskID IN ('001', '002', '003')
    

    This will cause each row being updated to output the new values (e.g. after the update) so you can check and see what gets updated, and to what values.

    Just ran the query and this is the results I get:

    ProjectID   TaskID  Date
       0       1    2009-10-28 00:00:00.000
       0       2    2009-12-01 00:00:00.000
       0       3    2010-02-24 00:00:00.000
       1       1    2009-10-28 00:00:00.000
       1       2    2009-12-01 00:00:00.000
       1       3    2010-02-24 00:00:00.000
       2       1    2009-10-28 00:00:00.000
       2       2    2009-12-01 00:00:00.000
       2       3    2010-02-24 00:00:00.000
    

    The dates for Projects 1 and 2 and Tasks 1,2,3 have been set to the values of the “master” project 0.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a table that looks like this: Project | State ---------------- 1 |
I have Servlet that looks something like this: public class MyServlet extends Servlet {
Hei guys i have this JQuery Ajax call from my view and it looks
I have an odd case where when I look at the data through my
I am trying to query a hasAndBelongsToMany relationship in Cakephp 1.3, but it looks
I have a DataGridView with a combobox column in it, showing the possible prices,
I'm trying to use WCF Data Service with Subsonic, but ran into this error
I am working on a project that obtains values from many measurement stations (e.g.
I'm experimenting with using the pg_bulkload project to import millions of rows of data
I just started a new project and wanted to use HaskellDB in the beginning.

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.