TSQL - 解析执行计划,以确定列由存储过程返回存储过程、计划、TSQL

2023-09-04 22:31:00 作者:爷de霸气√你值得拥有

有没有办法来动态地确定(从.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:

自动生成包装类存储过程第1部分,< A HREF =htt​​p://msdn.microsoft.com/en-us/library/ms973244.aspx相对=nofollow>第2部分 动态绑定您的数据层,以存储过程和SQL命令使用.NET元数据和反思 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...

 
精彩推荐