[英]How do I select particular column from executing reporting procedure
How can I select only particular column from a stored procedure: 如何仅从存储过程中选择特定列:
DECLARE @return_value int
EXEC @return_value = [dbo].[PositionsForNAV_PairTrades]
@ComparePeriod = 'MTD',
@OverrideCompareDate = '2010-12-31',
@PortfolioId = '5',
@OverrideStartDate = NULL,
@NewPositionsOnly = 0,
@ReportType = 0,
@SourceID = 13,
@SecurityType = 'Bond',
@LongShort = 1
GO
It is giving me many columns, please help me how can I select only 3-4 particular columns from the result. 它给了我很多列,请帮助我如何从结果中只选择3-4个特定列。
You can't use return values for this. 您不能使用返回值。 A stored procedure has a single return value and it is used for error codes / status values, not data.
存储过程具有单个返回值,它用于错误代码/状态值,而不是数据。 It is also restricted to integers.
它也仅限于整数。
You need to either create a #temp
table with the structure of the output to the stored procedure, then do: 您需要创建一个
#temp
表,其中包含存储过程的输出结构,然后执行:
INSERT #temp EXEC dbo.StoredProcedureName ...
SELECT col1, col2 FROM #temp;
Or you can use a variety of other hacks, like using OPENQUERY
against a loopback provider (which I'm not even going to show because I think it's a bad idea). 或者你可以使用各种其他的黑客攻击,例如对一个环回提供程序使用
OPENQUERY
(我甚至不打算显示它,因为我认为这是一个坏主意)。
For more ideas on sharing data between procedures, see: 有关在过程之间共享数据的更多想法,请参阅:
http://www.sommarskog.se/share_data.html http://www.sommarskog.se/share_data.html
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.