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
 Transact-SQL (2000)
 Insert into multiple tables from one

Author  Topic 

filthy
Starting Member

1 Post

Posted - 2006-10-23 : 11:03:47
Hi. New job, new to sql server, first task. Here goes:

source table: EMP (empId, name, hairColor, skinColor, birthCity)

I need to select date from EMP and insert into these tables:

HAIR_COLOR (hairColorId, colorName) id populated by sequence
SKIN_COLOR (skinColorId, colorName) id populated by sequence
BIRTH_CITY (birthCityId, cityName) id popluated by sequence

GO back and update a couple of columns in the EMP table (referential integrity). Total record count should be around 100,000.

How can i go about this?

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2006-10-23 : 11:19:13
[code]
insert into HAIR_COLOR(ColorName)
select distinct hairColor
from EMP

insert into SKIN_COLOR(ColorName)
select distinct skinColor
from EMP

insert into BIRTH_CITY(cityName)
select distinct birthCity
from EMP
[/code]



KH

Go to Top of Page
   

- Advertisement -