Hi
I am trying to pass this select statement using pymssql:
SELECT Customer_Key , Name , TerritoryID FROM Customer WHERE (NOT (Customer_Key LIKE '[ZZ]%'))
and keep getting this error:
ValueError: unsupported format character ''' (0x27) at index 91
How do I ues the % symbol in LIKE cluase for SQL statements?
It is a bug in pymssql. Until 1.0.2 is released you must use %% instead of %
yes, I finally got there, the big problem I thought was python being unhappy with the ' right after the % (as in this -> %' caused the problem)
I tried the like 'abc&&' but that failed to. My eventual solution was something like this:
SQL = "SELECT blah FROM table WHERE name LIKE 'abc" SQL += "%%" SQL += "' ORDER BY blah"
This should work:
SQL = "SELECT blah FROM table WHERE name LIKE 'abc%%' ORDER BY blah"
Sorry for the inconvenience, this bug slipped unnoticed.
There was no real inconvenience, and I learned a few things so that was good ;-)
Thanks,
Log in to post a comment.
Hi
I am trying to pass this select statement using pymssql:
SELECT Customer_Key , Name , TerritoryID FROM Customer WHERE (NOT (Customer_Key LIKE '[ZZ]%'))
and keep getting this error:
ValueError: unsupported format character ''' (0x27) at index 91
How do I ues the % symbol in LIKE cluase for SQL statements?
It is a bug in pymssql. Until 1.0.2 is released you must use %% instead of %
yes, I finally got there, the big problem I thought was python being unhappy with the ' right after the % (as in this -> %' caused the problem)
I tried the like 'abc&&' but that failed to. My eventual solution was something like this:
SQL = "SELECT blah FROM table WHERE name LIKE 'abc"
SQL += "%%"
SQL += "' ORDER BY blah"
This should work:
SQL = "SELECT blah FROM table WHERE name LIKE 'abc%%' ORDER BY blah"
Sorry for the inconvenience, this bug slipped unnoticed.
There was no real inconvenience, and I learned a few things so that was good ;-)
Thanks,