Skip to content
Advertisement

How to solve this error “ERROR 102 sql state 420000” which comes up when I try to create this procedure

I am trying to create a procedure which check whether the number entered (as a nvarchar type) already exists or not. If it exists then the updation takes place, else an error is thrown out to the user. But am not able to create the procedure because as soon as I execute the command ERROR 102/156 SQL STATE 42000 comes up.

FYI I use Microsoft SQL Server. How to clear this error and create the procedure?

Advertisement

Answer

Conditionally UPDATE and see if any changes happened

Otherwise in a concurrent environment something may happen between

and

renderring the if check useless

User contributions licensed under: CC BY-SA
2 People found this is helpful
Advertisement