google-code-export / pymssql

Automatically exported from code.google.com/p/pymssql
GNU Lesser General Public License v2.1
0 stars 0 forks source link

using like #63

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
I have a database i created using Micrososft SQL server express.
My database contains product names in a table called product ie Microsoft 
Office 2003, Microsoft Office 2007 etc

I tried querying the database using in Management studio:
 select product_id, product_name from product where product_name like 'Microsoft%'

and in my python script:

 query = 'select product_name, product_id, eol, eosl from product where product_name like ' + (query_test)

(Where query_test is an input from the user)

What is the expected output? What do you see instead?

The management studio query works, when I run the python script i get the 
following 

pymssql.OperationalError: SQL Server message 207, severity 16, state 1, line 1:
Invalid column name 'Microsoft'.

What version of the product are you using? On what operating system?

python 2.4, ms sql server express 2008, windows 7 x64 bit

Please provide any additional information below.

Ive tried having the query as a string, as a raw input, and nothing is working, 
i even tried running the query with hard coding microsoft as a string and as 
'....."Microsoft"' type query

Any questions please ask

Thank you

Original issue reported on code.google.com by haris...@googlemail.com on 2 Aug 2011 at 9:39

GoogleCodeExporter commented 9 years ago
print query before you run it.  Looks like your string is not coming together 
like you think it is.  Specifically, it looks like you are not quoting the 
input value.  Use the execute API as shown here:

http://code.google.com/p/pymssql/wiki/PymssqlExamples

Original comment by rsyr...@gmail.com on 2 Aug 2011 at 8:55