Hi,
This is a very newbie question of SQL Server Stored Procedure (I am using SQL Server 2008)
The following is a pseudo code of a SQL Server procedure
BEGIN TRY
BEGIN TRANSACTION
update MyTable1 set Field1 = @SomeValue where Field2 = @SomeValue2
IF @@ROWCOUNT = 0
BEGIN
END
update MyTable2 Set ....
insert into MyTable3 ....
COMMIT
END TRY
BEGIN CATCH
IF @@TRANCOUNT > 0
ROLLBACK
END CATCH
I have a couple of questions:
1. In the code above, on the first update I want to cancel if no record is found to be updated. How?
2. Is there a command END TRANSACTION is TSQL?
TIA
"The creative process is nothing but a series of crises." Isaac Bashevis Singer
"My experience is that as soon as people are old enough to know better, they don't know anything at all." Oscar Wilde
"If a nation values anything more than freedom, it will lose its freedom; and the irony of it is that if it is comfort or money that it values more, it will lose that too." W.Somerset Maugham