SELECT query and then use of @RowCount

From: chequerm (chequerm_at_discussions.microsoft.com)
Date: 09/22/04


Date: Tue, 21 Sep 2004 21:53:05 -0700

I have the following stored procedure which never fires the raiserror
condition. Even if I place an incorrect state in the proc after the select
state such as (SELECT * from tbl_foo) it still returns the recordset without
an error. The calling command is as follows
  (SQLDataReader) reader = SQLServer.ExecuteReader(Me.connectionString, sp,
id)
 
Note: When executed in the query analyzer the error is displayed. Any help
appreciated.
-----------------------------------------------
CREATE PROCEDURE usp_GetArticle
 @ArticleId int
AS
SELECT * FROM tbl_Article WHERE ArticleID = @ArticleId
IF @@RowCount = 0
        RAISERROR('RES_RecordNotFound', 18, 1)
-------------------------------------------------