gpt4 book ai didi

sql - 在 SQL 中返回空表的首选方法是什么?

转载 作者:行者123 更新时间:2023-12-04 01:31:34 26 4
gpt4 key购买 nike

我知道我可以使用以下查询返回一个空表:

select * from tbFoo where 1=2

但该代码对我来说并不好看。

有这样做的“标准”方式吗?

如果你想知道我为什么要做这么奇怪的事情,那是因为 I can't name the datatables I return from a stored procedure ,所以我需要空的占位符。

最佳答案

刚刚运行两者:

SELECT TOP 0 * FROM Table
and
SELECT * FROM Table WHERE 1=0

它们产生完全相同的执行计划。

关于sql - 在 SQL 中返回空表的首选方法是什么?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/590028/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com