Can I raise System Error in sql Server in a stored procedure.
- by Shantanu Gupta
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 ?