?
Solved

Select into tb.column from different tb.column

Posted on 2010-11-19
4
Medium Priority
?
233 Views
Last Modified: 2012-05-10
I have two tables, both contain employee_no and other column's, I need to 'copy' only the employee_no column into an existing tb, so that it can be updated with new information, how would I go about doing this?
0
Comment
Question by:JYLWest
4 Comments
 
LVL 52

Expert Comment

by:Carl Tawn
ID: 34173158
You mean something like:

   INSERT INTO [Table2] ([employee_no])
       SELECT [employee_no] FROM [Table1]

?
0
 
LVL 143

Expert Comment

by:Guy Hengel [angelIII / a3]
ID: 34173178
I think you want to UPDATE with JOIN ...
see this article: http://www.experts-exchange.com/A_1517.html
0
 
LVL 32

Accepted Solution

by:
Erick37 earned 1500 total points
ID: 34173266
Updates one table with info in another table joined on employee_no. ??

UPDATE a SET
   somecolumn = b.someothercolumn
FROM TableOne a
INNER JOIN TableTwo b ON a.employee_no = b.employee_no
0
 

Author Closing Comment

by:JYLWest
ID: 34831138
managed to come right but very close to where i needed to be.
0

Featured Post

Windows Server 2016: All you need to know

Learn about Hyper-V features that increase functionality and usability of Microsoft Windows Server 2016. Also, throughout this eBook, you’ll find some basic PowerShell examples that will help you leverage the scripts in your environments!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I've encountered valid database schemas that do not have a primary key.  For example, I use LogParser from Microsoft to push IIS logs into a SQL database table for processing and analysis.  However, occasionally due to user error or a scheduled task…
Use this article to create a batch file to backup a Microsoft SQL Server database to a Windows folder.  The folder can be on the local hard drive or on a network share.  This batch file will query the SQL server to get the current date & time and wi…
Loops Section Overview
With just a little bit of  SQL and VBA, many doors open to cool things like synchronize a list box to display data relevant to other information on a form.  If you have never written code or looked at an SQL statement before, no problem! ...  give i…

839 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