我可以在查看存储过程后返回自定义结果吗?结果?

发布于 2024-08-20 17:42:18 字数 53 浏览 3 评论 0原文

我想返回自定义值作为行的值,以防万一通过执行存储过程未获取任何行 - 有没有办法做到这一点?

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?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

蓝天 2024-08-27 17:42:18
if 0 = (select count(*) from tbl where conditions)
    select 'None' as s, 0 as n
else
    select s, n from tbl where conditions

如果行是从过程(而不是选择)返回的,则执行到临时表中,然后进行相同的练习。像这样:

create table #tmp (s varchar(17), n integer)

insert into #tmp
    execute myproc
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
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文