can i return a custom result after reviewing a stored procedures' result?
-
19-09-2019 - |
Question
I want to return custom values as the values of the rows in case when no rows are fetched by executing the stored procedure - is there a way to do that?
Solution
if 0 = (select count(*) from tbl where conditions)
select 'None' as s, 0 as n
else
select s, n from tbl where conditions
If the rows are returned from a procedure, as opposed to a select, execute into a temporary table, then the same excercise. Like this:
create table #tmp (s varchar(17), n integer)
insert into #tmp
execute myproc
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow