Issue 215: No results. Previous SQL was not a query.
Status:  Complete
Owner: ----
Closed:  Sep 2012
Reported by Anton.Do...@gmail.com, Oct 13, 2011
What steps will reproduce the problem?
1. cnxn = pyodbc.connect('DRIVER={SQL Server};SERVER=<server>;DATABASE=<db>;UID=user;PWD=pass')
2. cursor = cnxn.cursor()
3. cursor.execute("CREATE TABLE dbo.Approvals (ID SMALLINT NOT NULL IDENTITY PRIMARY KEY, HostName char(120));")


What is the expected output? What do you see instead?
I was expecting to get some sort of result, especially a new table in my database.

What i get: pyodbc.ProgrammingError: No results.  Previous SQL was not a query.


What version of the product are you using? On what operating system?
pyodbc-2.1.11.win32-py2.6
Python2.6
Windows 7
Microsoft SQL Server 2008 (Cluster)
ODBC Drver(s):
   SQL Server
   SQL Server Native Client 10.0

Please provide any additional information below.
I don't know what to say really, it's a strange dead-end problem which no one can seam to solve, any help would be appritiated!

Oh, i've tried both a internal SQL account and a Windonws native login both with full access and the same result.
I've changed query a couple of times but nothing really helps.

And the syntax Should be 100% perfect, it works if i run the command from a GUI.

Oct 14, 2011
#1 Anton.Do...@gmail.com
Is the issues section dead?

Looking back a few threads it sort of looks like it :/
If there's no support here i'll have to change module for the SQL part.
Oct 14, 2011
Project Member #2 mkleehammer
The issues section is not dead - I've just been extremely busy.

I don't know what is causing this.  Have you run the SQL Server unit tests?  Most of the 160+ tests are going to perform exactly what you are doing, which is why it is strange.

I recently had an issue with an out of date ODBC driver.  Installing the 2008R2 driver fixed it.

Side note: I usually use {SQL Server Native Client 10.0} when connecting to 2008 since that is the 2008 driver.  The {SQL Server} one is a 2000-compatible version.

I just ran your example and it worked as expected.  I'll look into it more later, but if this level of functionality didn't work all the time, I'd certainly have seen it before.  
Status: Investigating
Nov 2, 2011
Project Member #3 mkleehammer
Can you provide an ODBC trace for this?
Status: Hold
Mar 5, 2012
#4 gol...@gmail.com
I am seeing something similar and have submitted  issue 243  (https://code.google.com/p/pyodbc/issues/detail?id=243) with details of how to reproduce the problem with a stored procedure.
Apr 21, 2012
#5 theserge...@gmail.com
I just ran into the same problem.  Encoding the sql string as ascii solved the problem.
Sep 27, 2012
Project Member #6 mkleehammer
Closing because I believe this was fixed in 3.0.5.  Please reopen if you can reproduce.  Thanks.

Status: Complete