Can I raise System Error in sql Server in a stored procedure.
Posted
by Shantanu Gupta
on Stack Overflow
See other posts from Stack Overflow
or by Shantanu Gupta
Published on 2010-03-15T21:11:09Z
Indexed on
2010/03/15
21:19 UTC
Read the original article
Hit count: 224
I am writing a stored procedure where i m using try catch block.
Now i have a unique column in a table. When i try to insert duplicate value it throws exception with exception no 2627.
I want this to be done like this
if (exists(select * from tblABC where col1='value')=true) raiseError(2627)--raise system error that would have thrown if i would have used insert query to insert duplicate value
And which method will be better, using insert query or checking for duplicate value before insertion using Select query ?
© Stack Overflow or respective owner