尝试将数据插入表时出现上述错误,我也尝试了 SET NOCOUNT ON 选项,但仍然遇到同样的问题,
import pyodbc as p
connstr= 'DRIVER={SQL Server};SERVER=SQLEXPRESS;DATABASE=TEST;Trusted_Connection=yes;unicode_results=False'
conn = p.connect(connstr,charset='UTF-16')
print conn
cursor = conn.cursor()
try:
result = cursor.execute("""select col1 into tb2 from (select 1 as col1) tb1""")
except Exception as error:
print error
for each in result.fetchall():
print each