Transactions

Puiu

Well-known member
Joined
Oct 6, 2004
Messages
90
I have a stored procedure that makes an insert into a database. Something like
Code:
create proc InsAgent
@Name varchar(100),
@Age varchar(10),
@Message varchar(100) output

as 
insert into Agent values(@Name,@Age)
set @Message=Success

My questions: 1. is it worth to use transactions with this kind of stored proc ?

2. If i want to exit a stored procedure i should type return
In some cases i saw "return" followed by a number: return 11 or return 10...
Is there any use for that number ?
 
Hi,
if this is the only insert/update/delete you do then using transactions is overkill.
You should use transactions if you do multiple changes in the database that have to be all successful. Its not the case here, at least not from what youve shown.

HTH
/Kejpa
 
For the RETURN, I usually use RETURN 0 to indicate SUCCESS, but RETURN by itself works fine. Normally, a non-zero value indicates an error. Its typical to use "RETURN @@ERROR" in SQL Server.

-ner
 
Back
Top