I have a transaction I want to commit but unsure if it will be rolled back if anything fails. I know I can use a TransactionScope in c# and if an error occurs everything will be rolled back. But I am not so sure about a transaction in a stored procedure. All the examples online have a roll back with the ROLLBACK
keyword. What if I dont have a ROLLBACK keyword then what will happen?
CREATE PROCEDURE CreatePost
@type INT,
@name VARCHAR(500)
AS
BEGIN
DECLARE @insertedId TABLE(Id INT)
DECLARE @id INT
BEGIN TRANSACTION
INSERT INTO [Post] ([Name], [Type])
OUTPUT inserted.Id INTO @insertedId
VALUES (@name, @type)
UPDATE [Tables] SET Ordinals =ordinals + 1
WHERE Id = @tableId
COMMIT
END