SQL服务器提示:sp_help table_name。
我想使用Django访问此输出。
我正在使用django 2.1。我希望下面的代码可以工作,但是它只返回SQL Server返回的第一部分。
cursor = connection.cursor()
cursor.execute("sp_help testTable")
print(cursor.fetchall())
我希望输出为:
[('testTable', 'dbo', 'user table', datetime.datetime(2019, 10, 14, 16, 0, 46, 700000))]
[('testCol', 'varchar', 'no', '50', '', '', 'no', 'no', 'no', 'SQL_Latin1_General_CP1_CI_AS')]
[...more result sets...]
相反,我得到了:
[('testTable', 'dbo', 'user table', datetime.datetime(2019, 10, 14, 16, 0, 46, 700000))]
答案 0 :(得分:0)
多亏了Sean Lange的指导,我才发现我的问题与django无关。我需要使用:'cursor.nextset()'访问其他结果集。
cursor.nextset()