[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

SQL Update Querry

Posted on 2012-08-22
5
Medium Priority
?
646 Views
Last Modified: 2012-08-23
I need a SQL store procedure  that would look into two tables and use the 1st table as the source and the 2nd table as the target.
It needs to update the 2nd table info based on the 1st tabe data. Please look at this screenshot:
For instance in this screenshot I need to use the ceredian table to update the data in EmployeeLogin Table. I need a store procedure that would update the EmployeeLogin Department and Position for each employee. The common column between these two table is employee Number.
sample
0
Comment
Question by:pauledwardian
5 Comments
 
LVL 25

Accepted Solution

by:
lwadwell earned 1520 total points
ID: 38323476
something like:
UPDATE EmployeeLogin 
SET EmployeeLogin.Position = Ceredian.Postion
  , EmployeeLogin.DepartmentName = Ceredian.Dept
FROM EmployeeLogin 
JOIN Ceredian ON EmployeeLogin.EmployeeNo = Ceredian.EmpNum

Open in new window

0
 
LVL 9

Assisted Solution

by:selva_kongu
selva_kongu earned 160 total points
ID: 38323513
UPDATE EL
SET EL.Position = C.Postion
  , EL.DepartmentName = C.Dept
FROM EmployeeLogin EL
INNER JOIN Ceredian C ON EL.EmployeeNo = C.EmpNum
0
 
LVL 9

Assisted Solution

by:Vijaya Reddy Pinnapa Reddy
Vijaya Reddy Pinnapa Reddy earned 160 total points
ID: 38323526
Creating procedure:

CREATE PROCEDURE UpdateEmpNo
AS
begin
UPDATE EmployeeLogin
SET EmployeeLogin.Position = Ceredian.Postion, EmployeeLogin.DepartmentName = Ceredian.Dept FROM EmployeeLogin INNER JOIN Ceredian ON EmployeeLogin.EmployeeNo = Ceredian.EmpNum
End

Executing procedure:
exec UpdateEmpNo
0
 
LVL 143

Assisted Solution

by:Guy Hengel [angelIII / a3]
Guy Hengel [angelIII / a3] earned 160 total points
ID: 38323549
0
 

Author Closing Comment

by:pauledwardian
ID: 38327367
Thank you guys!!
0

Featured Post

Important Lessons on Recovering from Petya

In their most recent webinar, Skyport Systems explores ways to isolate and protect critical databases to keep the core of your company safe from harm.

Question has a verified solution.

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

This article explains how to reset the password of the sa account on a Microsoft SQL Server.  The steps in this article work in SQL 2005, 2008, 2008 R2, 2012, 2014 and 2016.
This shares a stored procedure to retrieve permissions for a given user on the current database or across all databases on a server.
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…

834 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