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 |
|
daniel.newman@bis-web.net
Yak Posting Veteran
71 Posts |
Posted - 2001-06-11 : 11:48:35
|
| I know you keep saying "don't use cursors", but I'm going to need some help on how to do a recursive couple of commands on something that resembles very much a cursor.My SP is currently only assuming it will return one figure from the database, and then action on that, but I need to build in the fact that more than one record may match, so it will have to loop through them.This is what I have so far:CREATE PROCEDURE dbo.xxx_RemoveThisUser @email varchar(100)ASDECLARE @UserID intSELECT @UserID = UserID FROM Users WHERE Email = @email -- only returns one at present/* potential loop in here*/DELETE FROM Address WHERE UserID = @UserIDDELETE FROM Institution WHERE UserID = @UserIDDELETE FROM Postcode WHERE UserID = @UserIDDELETE FROM Users WHERE UserID = @UserIDDELETE FROM Users_on_Lists WHERE UserID = @UserID/* end loop */GOSo how can I build in a looping code block without using cursors?Sorry if this is too basic for a monday morning, but there you go :)Thanks for helping,Daniel Newman. |
|
|
|
|
|