Quantcast
Channel: Transact-SQL forum
Viewing all articles
Browse latest Browse all 12890

DELETING multiple rows

$
0
0

I am trying to delete rows from two tables the relevant information is the same as in this thread:

https://social.msdn.microsoft.com/Forums/en-US/0fc621b8-bbb4-442e-8812-088fbc2833c6/insert-into-two-linked-tables-via-query-designer-in-visual-studio?forum=transactsql

If I do any joining it is by DateId from both tables.

I need to Delete Name from Roster And Date And Area from RosterTimesonly if they equal the Parameters in the stored procedure. Here is my code which only deletes from Roster and not RosterTimes:

CREATE PROCEDURE [dbo].[DeleteRoster]
	@Name nvarchar(50),
	@Area nvarchar(50),
	@DDate Date
AS
BEGIN TRY

BEGIN TRANSACTION

DELETE FROM Roster FROM Roster INNER JOIN RosterTimes ON Roster.DateId = RosterTimes.DateId WHERE (Roster.Name = @Name)
DELETE FROM RosterTimes FROM  Roster INNER JOIN RosterTimes ON Roster.DateId = RosterTimes.DateId WHERE (RosterTimes.DatetoWorship = @DDate) AND (RosterTimes.WorshipArea = @Area)

COMMIT TRANSACTION

END TRY

BEGIN CATCH

           ROLLBACK TRANSACTION

END CATCH


RETURN 0


Once you eliminate the impossible, whatever remains, no matter how improbable, must be the truth. - "Sherlock holmes" "speak softly and carry a big stick" - theodore roosevelt. Fear leads to anger, anger leads to hate, hate leads to suffering - Yoda. Blog - http://www.computerprofessions.co.nr



Viewing all articles
Browse latest Browse all 12890

Trending Articles