TSQL - 解析执行计划,以确定列由存储过程返回 [英] TSQL - Parse Execution Plan to determine columns to be returned by a stored procedure

查看:97
本文介绍了TSQL - 解析执行计划,以确定列由存储过程返回的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有办法来动态地确定(从.NET code或TSQL)的列的存储过程将返回?我想动态生成.NET包装功能为我的存储过程。这是很容易得到PROC名称/参数/等。但我也想知道会当一个过程返回的数据(不执行该SP)哪些列。这可能吗?

Is there a way to dynamically determine (from .NET code or TSQL) the columns a stored procedure will return? I would like to dynamically generate wrapper functions in .NET for my stored procedures. It is easy to get proc names/parameters/etc. but I would also like to know what columns to expect when a procedure returns data (without executing that SP). Is this possible?

推荐答案

我已经看到了它做了,然后我喊了客户端的开发是谁做的,我们离开的念头。

I've seen it done, then I shouted at the client developer who did it and we moved away from the idea.

说真的,我们有问题,嵌套特效,添加列或参数(以后使用等),和其他的东西,因为反射第二猜到我们的意图。

Seriously, we had problems with nested procs, adding columns or parameters (for later use etc), and other stuff because reflection second guessed our intentions.

但是,也有在其上MSDN文章:

However, there are MSDN articles on it:

  • Auto-Generating Wrapper Classes for Stored Procedures Part 1, part 2
  • Dynamically Bind Your Data Layer to Stored Procedures and SQL Commands Using .NET Metadata and Reflection

编辑:基于其他答案,我们通常不会根据IF语句改变输出。我们把视图存储的特效为方法(其中合理的,当然),所以需要一个稳定的签名......

based on other answers, we don't normally change output based on IF statements. We treat view stored procs as methods (where sensible of course) so require a stable signature...

这篇关于TSQL - 解析执行计划,以确定列由存储过程返回的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆