transfer data in one table to another table's column

Posted on 2013-09-27
Medium Priority
Last Modified: 2013-09-29
I have two tables.  AttendanceGrid and frmRegistrationCSW.  AttendanceGrid has duplicated IDs and frmRegistrationCSW has NO duplicated IDs

I have several records in frmRegistrationCSW where the ID is related to the ID in AttendanceGrid.  For example ID # 784 in frmRegistrationCSW is the referenced to ID # 784 in AttendanceGrid

There is an Age column in frmRegistrationCSW that I would like to copy to all equivalent records in AttendanceGrid.AgeReg

Is the following code correct for doing this?

SET R14.AgeReg= R13.Age
from AttendanceGrid R14
INNER JOIN frmRegistrationCSW AS R13
      ON R13.ID = R14.ID
      AND R13.fiscal = 2014

Open in new window

Question by:al4629740
LVL 13

Accepted Solution

sameer2010 earned 1000 total points
ID: 39529514
This is correct.
LVL 25

Assisted Solution

TempDBA earned 1000 total points
ID: 39529699
Its perfectly fine. That's how we update a table when joining with other table.

Featured Post

Build your data science skills into a career

Are you ready to take your data science career to the next step, or break into data science? With Springboard’s Data Science Career Track, you’ll master data science topics, have personalized career guidance, weekly calls with a data science expert, and a job guarantee.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

It is possible to export the data of a SQL Table in SSMS and generate INSERT statements. It's neatly tucked away in the generate scripts option of a database.
Ready to get certified? Check out some courses that help you prepare for third-party exams.
This video shows how to set up a shell script to accept a positional parameter when called, pass that to a SQL script, accept the output from the statement back and then manipulate it in the Shell.
Using examples as well as descriptions, and references to Books Online, show the documentation available for datatypes, explain the available data types and show how data can be passed into and out of variables.

621 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question