Access second result set of stored procedure with SQL or other work-around? Python\\pyodbc

南笙酒味 提交于 2019-11-29 09:58:05

No need for anything fancy. Just use nextset:


import pyodbc

db = pyodbc.connect ("")
q = db.cursor ()
q.execute ("""
SELECT TOP 5 * FROM INFORMATION_SCHEMA.TABLES
SELECT TOP 10 * FROM INFORMATION_SCHEMA.COLUMNS
""")
tables = q.fetchall ()
q.nextset ()
columns = q.fetchall ()

assert len (tables) == 5
assert len (columns) == 10

There are a few possible methods here. If the result sets are all the same, you might be able to use the INSERT...EXEC method. Otherwise OPENQUERY might work.

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!