Select value,
CASE count(value)
when 1 then convert(varchar, count(value)) + ' time'
else convert(varchar, count(value)) + ' times'
END as 'Number of Times'
from tablename
group by value
IF @@err <> 0
BEGIN
RAISERROR ('Unable to UPDATE table totalvalues due to database error number: %d',10,1,@err)
RETURN 1
END
RETURN 0
And make sure your front-end app responds to the return values (that aren't 0 in this case). You can then have your application (via ADO (rollbacktrans), MTS (setabort), etc.) ROLLBACK the transaction if you get the error reported to you in the proc.
If everything works, then COMMIT the transaction in ADO (committrans), MTS (setcomplete)...
If only SQL Server is calling the proc and no front-end will call it, then put your transaction management functionality in the proc via ROLLBACK TRANSACTION and COMMIT calls...
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.