You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to pyodbc
code:
record = 1
statement = """SELECT * FROM (
SELECT TOP 1 * FROM (
SELECT TOP ? *
FROM Inventory
ORDER BY ID ASC
) AS FOO ORDER BY ID DESC
) AS BAR ORDER BY ID ASC"""
print statement
rows = self.cursor.execute(statement, record).fetchone()
error:
pyodbc.ProgrammingError: ('42000', "[42000] [Microsoft][SQL Server
Native Client 10.0][SQL Server]Incorrect syntax near '@P1'. (102)
(SQLExecDirectW); [42000] [Microsoft][SQL Server Native Client 10.0]
[SQL Server]Statement(s) could not be prepared. (8180)")
I've googled extensively and haven't found anything, that makes think
that either a) I'm doing something stupid (more likely) or b) I'm
trying to do something that's not very common (less likely)
Can anyone point me in the right direction? Thanks!
ashaner
unread,
Jul 19, 2011, 4:02:56 PM7/19/11
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to pyodbc
Regarding the use of a parameter for the "top ?" portion I believe
you're c) doing something invalid. Why not just use python formatting
("...top %i..." % record)
instead?