Skip to content
Advertisement

pyodbc Incorrect syntax near ‘-‘. (102)

I am trying to select all data from table that contains “-” dash symbol, and i get error

This is code:

It prints out correct SQL statement SELECT * FROM [Table-Name] and in Microsoft SQL Management Studio this query works just fine with copy paste, but it wont work from python console

Same thing is with:qStr = 'SELECT * FROM "' + tableName + '"

Why is this happening, how can i get around it?

Advertisement

Answer

Try using Brackets wherever there is dash.

User contributions licensed under: CC BY-SA
11 People found this is helpful
Advertisement