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
 SQL Server 2000 Forums
 SQL Server Development (2000)
 sELECT THEN INSERT IN ONE BATCH

Author  Topic 

AskSQLTeam
Ask SQLTeam Question

0 Posts

Posted - 2002-05-28 : 08:42:49
lionchatta writes "i have tbl_location which includes userid, building, room. i combine the building and room into one feild called mailstop

SELECT Userid, Building +'/'+Room AS mailstop
FROM tbl_Location

i then want to take this recordset and insert it into a feild called mailstop in my tbl_employee. but they must based upon the userid of the location table and employee table. so the userid of the location table must match the userid of the employee table and insert that mailstop value into the mailstop feild in employee table. i want to get this right the first time. any help would be greatly appreciated."

JustinBigelow
SQL Gigolo

1157 Posts

Posted - 2002-05-28 : 08:52:45
If you want to get this right the first time then leave the two tables as they are. Anytime you want to find out which mail stop an employee is at you join the two tables. For example...

select e.username, l.building + ' ' + l.room as "Mail Stop"
from tbl_employees e inner join tbl_location l
on e.userid = l.userid
where e.userid like 'jsmith'

If you store the same data in two seperate tables you run the risk of data getting out of sync on updates and are losing the benefit of relational data storage.

m2c,
Justin



Edited by - justinbigelow on 05/28/2002 08:53:45
Go to Top of Page
   

- Advertisement -