Hi there.
i would like this procedure to delete all rows in 'sale' where date_modified < (getdate() +0.02) and all the related rows from 'sale_detail' and 'sale_address' i have written the code below, but ti think this might only delete one row from sale and its related rows in the other tables. Is this correct or will it detele all entries from sale etc. If not any suggestions?
Thanks...
CREATE PROCEDURE Sale_DeleteSaleTimedOut
AS
set nocount on
DECLARE
@sale_id int
select @sale_id = sale_id from sale where date_modified < (getdate() +0.02)
IF (@sale_id is NOT NULL) AND (@sale_id <> '')
BEGIN
delete sale_detail WHERE sale_id = @sale_id
delete sale_address WHERE sale_id = @sale_id
delete sale WHERE sale_id = @sale_id
END
set nocount off