I was wondering what I would have to do to throw an exception on the following stored procedure if there were 0 results so it could select the NULL row? This is for MSSQL, thanks so much.
...
BEGIN TRY
-- SET NOCOUNT ON added to prevent extra result sets from
-- interfering with SELECT statements.
SET NOCOUNT ON;
SELECT
NoteId,
Url,
Subject,
Content,
ExpiresAt,
RemindAt
FROM dbo.browsingnotes_Notes
WHERE UserId = @UserId
AND Hash = @Hash
END TRY
BEGIN CATCH
SELECT
NULL AS 'NoteId',
NULL AS 'Url',
NULL AS 'Subject',
NULL AS 'Content',
NULL AS 'ExpiresAt',
NULL AS 'RemindAt'
END CATCH
Does
RAISERRORwork? Or, as @Candie notes,THROWin SQL 2012You could check
@@RowCountafter the first select, and if 0, select the second.