Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
AskSQLTeam
Ask SQLTeam Question
0 Posts |
Posted - 2001-03-29 : 07:34:07
|
Mei Dong writes "Hi,
I have a question about system error messages. Say, I have a table named "tab". tab_id is the PK in tab table. If I run the following query:
insert into tab( tab_id) values ( 1 )
insert into tab( tab_id) values ( 1 ) if @@error <> 0 select ErrorFound = 1 else select ErrorFound = 0
I got the following error message: Server: Msg 2627, Level 14, State 1, Line 0 Violation of PRIMARY KEY constraint 'PK_tab'. Cannot insert duplicate key in object 'tab'. The statement has been terminated. ErrorFound ----------- 1
However all I want is the return value of ErrorFound. Is there a way to turn off the system error message and just return the recordset back? I was trying to look up in the SQL book online, but could not find any solution.
Any suggestion is greatly appreciated
Mei" |
|
|
|
|
|