FMTONLY vs TOP 0
如果我只需要检索结果的元数据,那么使用 FMTONLY 与“select top 0 ...”有什么区别?
If I needed to retrieve only metadata of a result, what is the difference between using FMTONLY vs. a "select top 0 ..." ?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您无法使用 SELECT TOP 0 来查找存储过程返回的内容,但可以使用 FMTONLY 来查找。
You can't use SELECT TOP 0 to find out what an stored procedure returns whereas you can use FMTONLY for that.
我对此也很感兴趣,经过一番谷歌搜索后,我发现 FMTONLY 是标准选项,例如 Select top 0 / SELECT What WHERE 1=0 因为正如 Icarus 所说,你不能使用 SELECT TOP 0 来查找存储过程返回的内容。
此外,当使用 FMTONLY 时,Sql 服务器不会生成/编译执行计划,因为该语句实际上并未被执行。
FMTONLY 是 SSRS / Visual Studio 在读取存储过程以获取列名称时使用的方法。
I was interested in this too, after a bit of googling I found that FMTONLY is the standard vs options like Select top 0 / SELECT whatever WHERE 1=0 because as Icarus said you cant use SELECT TOP 0 for finding out what a stored proc returns.
Also when using FMTONLY Sql server wont generate / compile an execution plan since the statement isnt actually being executed.
FMTONLY is the method SSRS / Visual Studio uses when reading stored procs to get the column names.