changing primary key value

Last Reply on Jan 10, 2013 06:52 AM By lucky1527

Posted on Jan 08, 2013 04:59 AM

hi

i want to experiment that can we change the primary key value

I am making a table Employee with Id as primary key and name as other columns

and another table salery with emp_id as foreign key and salary as another column

on windows form

on button 1 click data should be inserted on both the tables is it possible

or i have to save the employee table first and then salary table

is it possible to give temperory id in salary as -1 -2 -3 and after inserting data in employee table it should take that id and replace with this one

Results 1 - 5 of 10 12
Posted on Jan 08, 2013 05:16 AM

If you created  Salary Table with EmpId column as foreign key with Employee table EmpId. then you must insert data first in Employee table then salary table. 

Note: If you set foreign key Relationship then foreign key column value must match with primary column value


Posted on Jan 08, 2013 05:31 AM

yeah you are right but

is there is any procedure to do so


Posted on Jan 08, 2013 05:44 AM

no i don't know any, but you can try like,

insert dummy empId in Employee table and use that dummy EmpId to insert data in salary table.


Posted on Jan 08, 2013 05:47 AM

how can i do this any example


Posted on Jan 08, 2013 06:38 AM

insert dummy value like EmpId ='Emp001', EmpName ='DummyUserName'. In Employee table.

and use that EmpId to every insert in Salary table.