title: pyodbc Incorrect syntax near '-'. (102)
body: <p>I am trying to select all data from table that contains "-" dash symbol, and i get error</p>
  
  <pre><code>    cursor.execute(qStr)
  pyodbc.ProgrammingError: ('42000', "[42000] [Microsoft][ODBC SQL Server Driver][SQL Server]Incorrect syntax near '-'. (102) (SQLExecDirectW)")
  </code></pre>
  
  <p>This is code:</p>
  
  <pre><code>cnxn = pyodbc.connect('DRIVER={SQL Server};SERVER=192.168.2.100\name;DATABASE=base;UID=user;PWD=pass')
  
  try:
      cursor = cnxn.cursor()
  except e:
      if e.__class__ == pyodbc.ProgrammingError:        
          conn == reinit()
          cursor = conn.cursor()
  
  def checkIfEmpty (tableName):
      qStr = 'SELECT * FROM [' + tableName + ']'
      print(qStr)
      cursor.execute(qStr)
      asd=cursor.fetchone()
      if asd==None:
          return True
      else:
          return False
  </code></pre>
  
  <p>It prints out correct SQL statement <code>SELECT * FROM [Table-Name]</code> and in Microsoft SQL Management Studio this query works just fine with copy paste, but it wont work from python console</p>
  
  <p>Same thing is with:<code>qStr = 'SELECT * FROM "' + tableName + '"</code></p>
  
  <p>Why is this happening, how can i get around it?</p>