Best practices for throwing exceptions from SQL in C #

What are some good ways to eliminate business logic exceptions or return values ​​from SQL in C #? For example, when creating a new user, if the user already exists, the system and the user must be notified. I used a method raise_error()with a specific int state value, I used a stored procedure that returns int values, and I also selected the msg column with a specific structure. Are there any recommendations for this?

+3
source share
1 answer

I always do two things:

  • use the raiseerror function, which appears on the code side as an exception, and
  • return error code

#,

[sql- try-catch, ]

+1

Source: https://habr.com/ru/post/1698015/


All Articles