多次调用存储过程并仅处理返回的三个表中的一个 [英] Call a stored procedure multiple times and process only one of the three table which gets returned

查看:137
本文介绍了多次调用存储过程并仅处理返回的三个表中的一个的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试从SQL SERVER 2008数据库中提取数据。以下是我的任务描述:



1.我有记录列表(比方说100)我使用数据库中的SQL查询进行提取。



2.每个记录的某些特定列应该输入到存储过程。存储过程返回三个表作为输出。



3.我将只捕获三个表中的一个并使用另一个SQL查询过滤列数据。



4.如果上述过滤条件正确,我会将列数据(步骤1)保存在Excel中。



5.我将不得不重复所有100条记录的过程,并将过滤后的数据保存在Excel中。



我认为它使用以下选项,但我陷入困境,无法继续前进:



1.使用SSIS



2.使用嵌套游标



这样做的一个选择是为SP创建一个用户定义的函数,但由于数据在生产环境中,我无法这样做。 br />


请让我知道我可以用更简单的方式完成的任何过程。

I am trying to extract data from SQL SERVER 2008 database.Following is the description my task:

1. I have list of records(lets say 100) which I did extract using a SQL query from the database.

2. Some specific columns of each record should be given input to a stored procedure. The stored procedure returns three tables as the output.

3. I will have to catch only one of the table out of three and filter the columns data using another SQL query.

4. If the above filter condition is correct,I will save the column data(of step 1) in an excel.

5. I will have to repeat the process for all the 100 records and save the filtered data in an excel.

I considered it doing with below options but I am stuck and not able to proceed further:

1. Using SSIS

2. Using Nested Cursors

One option of doing that is by creating a user defined function for SP but I cannot do it because the data is in production environment.

Please let me know any process with which I can do it in a simpler manner.

推荐答案

< I> 1。我有一个记录列表(比方说100),我使用数据库中的SQL查询进行提取。

2.每个记录的某些特定列应该输入到存储过程。存储过程返回三个表作为输出。

3.我将只捕获三个表中的一个并使用另一个SQL查询过滤列数据。

我不明白你为什么只想从SP返回的3个表中过滤掉一个表。



4。如果上面的过滤条件正确,我会将列数据(步骤1)保存在Excel中。

5.我将不得不重复所有100条记录的过程并保存过滤后的数据在excel中。


对不起......你知道如何结构化查询语言 [ ^ ]有效吗?没有必要为所有100条记录重新调整ptocess。 SQL引擎可以比较所有这100条记录。结果集可以保存到Excel文件中。



我建议什么?从基础开始。 此处 [ ^ ]您将找到几个教程。



如需了解更多信息,请参阅:

教程:编写Transact-SQL语句 [ ^ ]

编写SQL查询:让我们从基础知识开始 [ ^ ]

用于Jet的OLE DB提供程序 [ ^ ]



请阅读上面的教程并回到这里并提出详细的问题。

干杯!
1. I have list of records(lets say 100) which I did extract using a SQL query from the database.
2. Some specific columns of each record should be given input to a stored procedure. The stored procedure returns three tables as the output.
3. I will have to catch only one of the table out of three and filter the columns data using another SQL query.

I do not understand why do you want to filter only one table from 3 returned by SP.

4. If the above filter condition is correct,I will save the column data(of step 1) in an excel.
5. I will have to repeat the process for all the 100 records and save the filtered data in an excel.

Sorry... Do you know how Structured Query Langage[^] works? There is no need to reapeat ptocess for all 100 records. SQL engine can compare all these 100 records. The result set can be saved to an Excel file.

What i suggest? Start with basics. Here[^] you'll find several tutorials.

For further information, please see:
Tutorial: Writing Transact-SQL Statements[^]
Writing SQL Queries: Let's Start with the Basics[^]
OLE DB Provider for Jet[^]

Please, read above tutorials and come back here with detailed question.
Cheers!


这篇关于多次调用存储过程并仅处理返回的三个表中的一个的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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