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 |
|
webfort
Starting Member
9 Posts |
Posted - 2007-02-09 : 08:27:45
|
| Hi, I have two tables one called students and location.I want to delete the location and all records in student corrosponding to that location, can any help or point me in the right direction.Many Thanks |
|
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2007-02-09 : 08:32:14
|
| BEGIN TRANDELETE FROM Students INNER JOIN Location ON Students.LocID = Location.IDWHERE Location.Name = 'SomePlace'DELETE FROM LocationWHERE Name = 'SomePlace'IF @@ERROR = 0 COMMIT TRANELSE ROLLBACK TRANPeter LarssonHelsingborg, Sweden |
 |
|
|
harsh_athalye
Master Smack Fu Yak Hacker
5581 Posts |
Posted - 2007-02-09 : 08:32:43
|
| [code]Delete sFrom Student s Join Location lon s.LocationID = l.LocationIDwhere l.location = 'somevalue'Delete LocationWhere location = 'somevalue'[/code]Harsh AthalyeIndia."The IMPOSSIBLE is often UNTRIED" |
 |
|
|
|
|
|