Loading ...

Related To Sql server database

Who is online?  0 guests and 0 members
home  »  forums   »  general topics   »  faq - frequently asked questions   » Related To Sql server database

Related To Sql server database

Posts under the topic: Related To Sql server database

Posted: 11/14/2009

Lurker 192  points  Lurker
  • Joined on: 10/23/2009
  • Posts: 20

hi

i have one problem

i have three tables named QuestionTable which have the primarey ker question_id

which refrances

two other tables named as Answer and Exam_Quesion so when i want to delete the data from question table then

 no data had dellted and exception is occuering

please help me thanks

naval kishor pandey

 


Posted: 11/14/2009

Guru 16813  points  Guru
  • Joined on: 4/19/2009
  • Posts: 490
  Answered

Hi, Naval

Yes you can't delete data from your parent table until you have data in your child tables. You have foreign key on your child tables which points to primary key in the main table so thats why you can t delete directly from parent table having primary key. If you are still in dilemma then please post  some test data .

 

Thanks,

Raghav


Posted: 11/14/2009

Contributor 2841  points  Contributor
  • Joined on: 11/29/2008
  • Posts: 62
  Answered

Hi Naval,
If you want to delete the data from Question(Parent  table) then first you need to delete data from Answer,Exam_Question (Child table) like:

Delete from Answer where QuestionId=@QuestionID
Delete from Exam_Question where QuestionId=@QuestionID
Delete from Question where QuestionId=@QuestionID



Posted: 11/14/2009

Lurker 192  points  Lurker
  • Joined on: 10/23/2009
  • Posts: 20

Thanks

Mr. Vijendar and raghav

My problem is solved.

naval kishor Pandey

 


Posted: 11/14/2009

Guru 16813  points  Guru
  • Joined on: 4/19/2009
  • Posts: 490

Cool.Cool


Page 1 of 1 (5 items)