在存储过程中多个select语句sql server 2005 [英] Multiple select statements in a stored procedure sql server 2005

查看:219
本文介绍了在存储过程中多个select语句sql server 2005的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

可以在单个存储过程中添加多个select语句。 select语句从同一个表获取数据。如果是,可以任何人提供一个例子,添加多个select语句,从存储过程中的不同表中检索数据。

Is it possible to add multiple select statements in a single stored procedure . The select statements are getting data from same tables. If yes, could anybody provide an example in adding multiple select statements, which retrieve data from different tables in a stored procedure.

其实我在国家,城市,大学,学院,部门在我的维护(同一)表。

Actually I am having list like state,city, university,college,department in my maintenance (same) table. As per the query i want execute the query and populate the value in my drop down list .

推荐答案

这个proc会返回多个结果设置到客户端

This proc will return mutiple result sets to the client

CREATE PROC whatever
AS
SELECT col1, col2 FROM Table1
SELECT col3, col4, col5 FROM Table2
SELECT col1, col3 FROM Table3
GO

可以使用DataAdaptor.Fill,然后可以使用DataTable(0),DataTable(1)和DataTable(2)

You can use DataAdaptor.Fill and then you can DataTable(0), DataTable(1) and DataTable(2)

或者使用 DataReader.NextResult

如果您有所有数据在一个表,那么你有一个坏的设计:查询表的sql性能

If you have "all data in one table" then you have a bad design: sql performance of a lookup table

这篇关于在存储过程中多个select语句sql server 2005的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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