Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 How to select into statement

Author  Topic 

EugeneLim11
Posting Yak Master

167 Posts

Posted - 2008-03-14 : 08:57:26
I have a table named Employee with the following fields

EmployeeID
EmployeeName
EmployeeDesignation
..
..

The column EmployeeDesignation is empty. (i.e. null values for all rows).

and another table named EmployeeDesignation

EmployeeID
Designation

Now I want to import all the data in EmployeeDesignation.Designation table to Employee.EmployeeDesignation Table where the EmployeeDesignation.EmployeeID = Employee.EmployeeID.

How do I do that ?

I tried selecting the designation into the table and I got an error saying "Employee table already exist."

any help is very much appreciated.

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2008-03-14 : 09:12:02
use UPDATE statement
UPDATE e
SET EmployeeDesignation = d.Designation
FROM Employee e INNER JOIN EmployeeDesignation d
ON e.EmployeeID = d.EmployeeID
WHERE e.EmployeeDesignation IS NULL




KH
[spoiler]Time is always against us[/spoiler]

Go to Top of Page

jimf
Master Smack Fu Yak Hacker

2875 Posts

Posted - 2008-03-14 : 09:14:08
Are you trying to update the EmployeeDesignation field in the Employee table with infornation in the Designation field of the EmployeeDesignation table?

JIm
Go to Top of Page

EugeneLim11
Posting Yak Master

167 Posts

Posted - 2008-03-14 : 21:38:30
Jim yes
Go to Top of Page
   

- Advertisement -