开发者

custom result after reviewing a stored procedures' result

I want to return custom values as the values of the rows in case when no rows are fetched by executing 开发者_Go百科the stored procedure

How do i do that?


You can use the built-in function ROW_COUNT() to test if any rows have been returned from a query. If the number of rows returned is zero, then you can run an alternative SQL statement to return your custom values:

--Execute your SQL statement
SELECT * FROM myTable

IF ROW_COUNT() = 0 
BEGIN
     --SQL to return your custom values instead
     SELECT value1, value2, etc.
END


Just do your own Select statement containing the values you want to return to the user. Something like this:

Select
   MyValue1,
   MyValue2,
   Myvalue3
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜