I know it sounds absurd but that is what I need to do.
table to store the child table after the updates. This
field. (It's actually a .txt file but I'm dumping into a
translate the artificial keys to natural keys. In my
the department_nm would be the natural key.
natural key is varchar. Although both are represented by a
number. So, it match exactly the example I gave.
>-----Original Message-----
>Carla,
>
>You cannot update child.department_id with
parent.department_nm. First of
>all, you cannot update an Int column with a varchar
column. Second, you're
>violating the referential integrity.
>
>What are you really trying to do.
>
>--
>-oj
>RAC v2.2 & QALite!
>
http://www.rac4sql.net >
>
>
>"Carla" <anonymous@discussions.microsoft.com> wrote in
message
>news:06a601c39796$dc628ac0$a501280a@phx.gbl...
>> create table parent_tb (
>> department_id int identity (1,1) primary key,
>> department_nm varchar(25))
>>
>> insert into parent_tb
>> (department_nm) values('finance')
>> insert into parent_tb
>> (department_nm) values ('marketing')
>> insert into parent_tb
>> (department_nm) values ('sales')
>> insert into parent_tb
>> (department_nm) values ('hr')
>>
>> create table child_tb (
>> employee_id int identity (1,1) primary key,
>> department_id int
>> references parent_tb(department_id),
>> employee_nm varchar(25))
>>
>> insert into child_tb
>> (department_id, employee_nm) values (1, 'Bob')
>> insert into child_tb
>> (department_id, employee_nm) values (2, 'Tim')
>> insert into child_tb
>> (department_id, employee_nm) values (3, 'Tom')
>> insert into child_tb
>> (department_id, employee_nm) values (3, 'Tom')
>>
>> -- now I need to update the department_id with
>> department_name. Something like this
>>
>> update child_tb
>> set department_id=parent_tb.department_nm
>> from parent_tb, child_tb
>> where parent_tb.department_id=child_tb.department_id
>>
>> -- But this way I get a cartisian product. I'm not sure
>> how I can do this update.
>>
>> -- Thanks in advance for your help.
>
>
>.