Showing posts with label student. Show all posts
Showing posts with label student. Show all posts

Sunday, March 25, 2012

Deleting foreign key record

Hi all,.

I have a table Student and the primarykey is studid..

This studid is the foreign key in another table called Class.

I want to delete the records in the table Class...

How can i do it..

Please help me...

Regards,

Mathewyou'll need to drop the foreign keys between the two tables delete the required data, and add the foriegn keys once again.|||

Quote:

Originally Posted by jamesd0142

you'll need to drop the foreign keys between the two tables delete the required data, and add the foriegn keys once again.


Hi James,

Is that the only method to delete those records??

Regards,
Mathew|||What error are you getting when you try to delete these records?

this will help me determine if i have suggested the correct method...

because you shouldnt really get any issues deleting a row frm the table 'class'

i can see y u wud get an error deleting a record from Student table however.|||

Quote:

Originally Posted by jamesd0142

What error are you getting when you try to delete these records?

this will help me determine if i have suggested the correct method...

because you shouldnt really get any issues deleting a row frm the table 'class'

i can see y u wud get an error deleting a record from Student table however.


Hi all,

I didnt try to delete record.. i have to do it,, before that i would like to know whether it is possible or not....

regards,
Mathew|||

Quote:

Originally Posted by mathewgk80

Hi all,

I didnt try to delete record.. i have to do it,, before that i would like to know whether it is possible or not....

regards,
Mathew


Ok, well as i said above, i can's see any problems with deleting from the 'class' table, although you might have a problem deletiung from the 'student' table because;

The studid field in the 'class' table would no longer have a lookup, so droping the foriegn keys first would allow you to delete a record in 'student', although if you have a value in the 'class' table for studid thats not in the 'student' table you 'shouldnt' be able to create the foriegn keys once again...

i hope you understand my logic here :ssql

Friday, February 24, 2012

Delete row from MS SQL Server 2000

Hi, I'm using SQL Server 2000 Personal Edition. I have created a table 'Student' which has 2 fields.

ID -- Varchar(10), Primary Key - contains ID of a student

NAME -- Varchar(50) -- contains names of student

ID NAME

0107200701 abcd

0107200702 cdgdh

0107200703 iyiylklk

.

.

I want to delete a complete row (all entries) from the "student" table using/specifing 'ID'. What will be the SQL query for that?

Hi

Try to use this (and please read help Wink )

delete from Student where [ID] = '0107200701'

You should change the ID to your real ID

Regards,

Janos