I have a SP (Stored procedure) which is contained of some T-SQL statements.....
All of T-sql statements are in a transaction block and by occuring any error, I rollback every thing.
like this:
BEGIN TRANSACTION
.....
.....
IF @X=1
BEGIN
declare cu cursor for select col1,col2 from Table1 where Id=@Y
open cu
fetch next from cuinto @A, @B
while @@Fetch_Status = 0
BEGIN
.....
......
IF @@ERROR <>0
BEGIN
ROLLBACK TRANSACTION
RETURN
END
END
.....
.....
The Sp does not run properly and I can't find what the resean of it is..... I think it's a good idea to log every operation within sp by inserting some data into a table My Question is:
Because it uses a transaction, every insertion will be rolled back.....
What's your opinion? Is there any other way?
Thank you