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.

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 Row Not Found Error Code

Author  Topic 

AskSQLTeam
Ask SQLTeam Question

0 Posts

Posted - 2006-01-19 : 08:38:18
rob writes "In Transact SQL I want to allow for a row not found on a SELECT:

e.g.

SELECT *
FROM NAMES
WHERE SURNAME = 'ANCHOVY'

IF NOT (@@ERROR = 0 OR @@ERROR = X)
PRINT "UNEXPECTED ERROR"

What is the X value?

Also is there a better way of doing this?

Thanks

Rob"

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2006-01-19 : 08:55:43
Did you execute that successfully?
How about using this?

If not exists(SELECT * FROM NAMES WHERE SURNAME = 'ANCHOVY')
--Row not found

or

SELECT * FROM NAMES WHERE SURNAME = 'ANCHOVY'

if @@RowCount=0
--Row not found


Madhivanan

Failing to plan is Planning to fail
Go to Top of Page
   

- Advertisement -