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.
| Author |
Topic |
|
mike009
Starting Member
15 Posts |
Posted - 2006-03-18 : 00:40:23
|
| hiif i have table employee with employee_id as a primary keyhow can i assign the primary key to the columns firstname and lastname?table structure is something like this :employee_id int not null, firstname varchar(20) not null, lastname varchar(20) not nullthe problem is that there is a foreign key in other table that referes to the table employee , so when i try to delete the primary key i get error said i can't delete coze it refers to other table ...other qif i create foreign key by this wayalter table le_orderadd constraint fk_salesman foreign key (Salesman_id) REFERENCES employeehow can i update this statement and addon delete set nulland to set it to null is that correct for first problemthxnote : sorry my english isn't good , if you please excuse me. |
|
|
chiragkhabaria
Master Smack Fu Yak Hacker
1907 Posts |
Posted - 2006-03-18 : 01:42:11
|
| you can delete the record from the primary table,when its the secondary table data.. The best thing is to write a small trigger on the primary table, either to delete the record from the secondary table or to set them to null..you can also you the option of Cascade delete. Just look in Book Online for ON DELETE CASCADEHope this helps..Sucess Comes to those who Believe in Beauty of their Dream.. |
 |
|
|
|
|
|