Tsql 如何在Visual Studio的服务器资源管理器中查询查询结果?

Tsql 如何在Visual Studio的服务器资源管理器中查询查询结果?,tsql,visual-studio-2013,subquery,server-explorer,sql-subselect,Tsql,Visual Studio 2013,Subquery,Server Explorer,Sql Subselect,我可以通过以下步骤从Visual Studio获取存储过程的结果: 0) Select View > Server Explorer 1) Locate the Data Connection that contains the SP of interest. 2) Right-click the SP and select Execute; if any args are required, it will allow you to populate those in a dialo

我可以通过以下步骤从Visual Studio获取存储过程的结果:

0) Select View > Server Explorer

1) Locate the Data Connection that contains the SP of interest.

2) Right-click the SP and select Execute; if any args are required, it will allow you to populate those in a dialog and then proceed with the execution
如果您提供了有效的参数(SP返回数据),结果将显示在T-SQL结果选项卡的网格中

但是,现在,如果要查询已返回的“数据集”,例如对特定列的值求和,可以从Visual Studio.Server Explorer.T-SQL中进行查询吗?如果是,怎么做

更新 我相信Khazratbek,但我只能通过右键单击数据连接下的Tables文件夹来实例化一个新查询:

SELECT SUM(QtyShipped), SUM(QtyOrdered) FROM CPSData.
…最后一个“.”后面的下拉列表中可用的选项不包含存储过程(SQLQuery1.sql)的结果


真的有可能吗?

服务器资源管理器-。右键单击表格->新建查询。编写查询(您可以从SP执行结果中选择),然后单击三角形符号。抱歉,如果我误解了您的确切问题。

让我们认为您的存储过程为您提供了用户的登录名和密码:

select login, password from users;
比如说,你拿一百万个结果为例。您不需要更改存储过程,但需要对结果进行一些处理(按某种顺序选择、更改顺序、按某种条件选择等等)。 让我们继续。存储过程提供了两列:一列是login,另一列是password。因此,我们可以将SP执行的结果视为某个表。要使用结果,请执行以下步骤:

服务器资源管理器->您的\u数据库\u连接->右键单击表->新建查询

然后在此处编写以下代码:

Declare @temporary_table_variable table(login varchar, password varchar); --or without datatypes 
insert into @temporary_table_variable(login, password) exec MyStoredProc; 
SELECT * from @temporary_table_variable where id > 1000; --it is just a simple example

希望有帮助

如何引用SP执行结果?SP的结果位于名为“SQLQuery1.sql”的选项卡中,但在选择“新建查询”后写入“SELECT*from”后出现的下拉列表中不包含“SQLQuery1.sql”…您尝试过吗<代码>声明@tablevar表(col1,…);插入@tablevar(col1,…)exec MyStoredProc'param1','param2';从@tablevar中选择col1、col2我不理解您的评论,但我已经能够根据您的答案运行查询。我的评论使用了一些临时表,它从存储过程中获取结果,您可以从该表中进行选择。我再补充一个答案