[英]How can I query the results of a query in Server Explorer in Visual Studio?
I can get the results of a Stored Proc from Visual Studio by following these steps: 通过执行以下步骤,我可以从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
Provided that you have provided valid args (and the SP returns data), the results will display in a grid in a T-SQL Results tab. 如果您提供了有效的参数(SP返回数据),结果将显示在“ T-SQL结果”选项卡的网格中。
Now, though, what if you want to query that "dataset" that has been returned, such as to sum the values of a particular column - can that be done right there from within Visual Studio.Server Explorer.T-SQL? 但是,现在,如果您要查询已返回的“数据集”,例如对特定列的值求和,该怎么办?可以在Visual Studio.Server Explorer.T-SQL中在那里进行? If so, how?
如果是这样,怎么办?
I believe Khazratbek, but I can only get this far in a New Query instantiated by right-clicking the Tables folder beneath the Data Connection: 我相信Khazratbek,但是我只能通过右键单击“数据连接”下面的“表”文件夹实例化的“新查询”来做到这一点:
SELECT SUM(QtyShipped), SUM(QtyOrdered) FROM CPSData.
...the options available as a drop down following that final "." ...作为最后一个“。”后面的下拉菜单可用的选项 do not contain the results of the Stored Proc (SQLQuery1.sql).
不包含存储过程(SQLQuery1.sql)的结果。
Is it really possible? 真的有可能吗?
Server Explorer -. 服务器资源管理器-。 Right click on Tables -> New query.
右键单击表格->新查询。 Write your query (you may select from your SP execution results) and just click on triangle sign.
编写查询(您可以从SP执行结果中选择),然后单击三角形符号。 Sorry, if I misunderstand your exact question.
抱歉,如果我误解了您的确切问题。
Let's think that your stored procedures gives you logins and passwords of users: 假设您的存储过程为您提供了用户的登录名和密码:
select login, password from users;
You are taking one million result, for example. 例如,您获得一百万个结果。 And you don't need to change your stored procedure, but you want to make some job with your results (selecting in some order, changing the order, select by some condition, so on).
而且,您无需更改存储过程,但希望对结果进行一些处理(以某种顺序选择,更改顺序,以某种条件选择,依此类推)。 Let's continue.
让我们继续。 Your stored procedure gives you a two column: it is column login and password.
您的存储过程为您提供了两列:这是列登录名和密码。 So we may consider the results of your SP execution as some table.
因此,我们可以将您的SP执行结果视为某些表。 To work with your result do next steps:
要处理结果,请执行以下步骤:
Server Explorer -> Your_database_connection -> Right click on Tables -> New query 服务器浏览器 -> Your_database_connection->右键单击表 -> 新建查询
Then write the following code there: 然后在其中编写以下代码:
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
Hope it helps 希望能帮助到你
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.