如何使用 select 在没有 DDL 操作的 SQL 服务器中新创建的 table 中显示静态行

How to show static row in newly created table in SQL Server WITHOUT DDL operation using select

我创建了一个新的 table。

我们需要输出:

Table: User
columns: id|name|date
values : 0 | 0  |0

如果 table 包含值则不显示静态数据

注意:只使用select

听起来好像您正在寻找条件 UNION:

select id, name, date
from the_table
union all
select 0, '', null
where not exists (select * from the_table);

联合的第二部分 returns 常量值,但前提是 the_table 不包含任何行。