从存储过程创建游标 [英] Creating Cursor from Stored Procedure
问题描述
大家好!
我想在t-sql中创建一个游标。问题是我想使用
存储过程而不是光标中的select命令。
有人能告诉我如何使用存储过程''/ p创建
游标?
我正在使用sql 2000和.net 2.0
谢谢,
幸运
Hi guys!
i want to create one cursor in the t-sql. the problem is i want to use
stored procedure instead of select command in cursor.
can anyone tell me how can i use stored procedure''s o/p to create
cursor?
i''m using sql 2000 and .net 2.0
thanks,
Lucky
推荐答案
首先,尝试重写你的应用程序,这样你就不会t使用游标。
其次,如果你必须使用游标,你可以创建一个临时表来保存存储过程的输出,然后再输出
从中构建一个游标;
例如:
CREATE TABLE #splat(列表列表)
INSERT INTO# splat
exec myproc
DROP TABLE #splat
Stu
Lucky写道:
First, try to rewrite your app so you don''t use cursors.
Second, if you must use a cursor, you can create a temp table to hold
the output of your stored procedure, and then build a cursor from that;
e.g.:
CREATE TABLE #splat (columnlist)
INSERT INTO #splat
exec myproc
DROP TABLE #splat
Stu
Lucky wrote:
大家好!
我想在t-sql中创建一个游标。问题是我想使用
存储过程而不是光标中的select命令。
任何人都可以告诉我如何使用存储过程''/ p创建游标?
我正在使用sql 2000和.net 2.0
谢谢,
幸运
Hi guys!
i want to create one cursor in the t-sql. the problem is i want to use
stored procedure instead of select command in cursor.
can anyone tell me how can i use stored procedure''s o/p to create
cursor?
i''m using sql 2000 and .net 2.0
thanks,
Lucky
>
发布您的确切要求。可以有更好的方法你现在要做什么?b $ b现在要做什么
Madhivanan
Lucky写道:
Post your exact requirement. There can be better method of what you are
trying to do now
Madhivanan
Lucky wrote:
大家好!
我想在t-sql中创建一个游标。问题是我想使用
存储过程而不是光标中的select命令。
任何人都可以告诉我如何使用存储过程''/ p创建游标?
我正在使用sql 2000和.net 2.0
谢谢,
幸运
Hi guys!
i want to create one cursor in the t-sql. the problem is i want to use
stored procedure instead of select command in cursor.
can anyone tell me how can i use stored procedure''s o/p to create
cursor?
i''m using sql 2000 and .net 2.0
thanks,
Lucky
>
Stu写道:
首先,尝试重写你的应用程序,这样你就不会使用游标。
First, try to rewrite your app so you don''t use cursors.
>
其次,说真的。尝试重写你的应用程序,这样你就不会使用游标。
您也可以考虑将存储过程的内容放入
a用户定义函数返回一个表。然后你就可以使用那个
UDF来存储过程和使用
游标的粗略的东西。
祝你好运!
Jason Kester
外籍软件咨询服务
http://www.expatsoftware.com/
---
获取自己的旅游博客,行程地图和照片!
http://www.blogabond.com/
Second, Seriously. Try to rewrite your app so you don''t use cursors.
You might also consider dropping the guts of your stored procedure into
a User Defined Function that returns a table. Then you can use that
UDF for both the Stored Procedure and your sketchy thing that uses
Cursors.
Good luck!
Jason Kester
Expat Software Consulting Services
http://www.expatsoftware.com/
---
Get your own Travel Blog, with itinerary maps and photos!
http://www.blogabond.com/
这篇关于从存储过程创建游标的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!