|
From: mscertified on 18 Jul 2008 13:57 In my sproc, have a SELECT which should always return ONE row. However, I'd like to trap if returns zero rows or >1 row. How could I do this using TRY...CATCH ? Thanks
From: SQL Menace on 18 Jul 2008 14:02 Why wouldn't you use @@ROWCOUNT instead? Denis The SQL Menace http://www.lessthandot.com/ http://sqlservercode.blogspot.com http://sqlblog.com/blogs/denis_gobo/default.aspx On Jul 18, 1:57 pm, mscertified <rup...(a)tigerlily.com> wrote: > In my sproc, have a SELECT which should always return ONE row. > However, I'd like to trap if returns zero rows or >1 row. > How could I do this using TRY...CATCH ? > > Thanks
From: Plamen on 18 Jul 2008 14:50 Seems you posted this question twice, here is a copy/paste from my reply to your first one: Immediately after the select statement you can check the row count and raise an error that will be trapped in the catch section: IF @@ROWCOUNT > 1 RAISERROR('More than one rows.', 16, 1) HTH, Plamen Ratchev http://www.SQLStudio.com
|
Pages: 1 Prev: join data from multiple tables with no keys Next: Stored Proc problem |