title: Pyodbc- If table exist then don't create in SSMS
body: <p>I am trying something like:</p>
  
  <pre><code>import pyodbc
  
  cnxn = pyodbc.connect(driver ='{SQL Server}' ,server ='host-MOBL\instance',database ='dbname', trusted_connection = 'yes' )
  cursor = cnxn.cursor()
  
  
  cursor.execute("""SELECT * FROM INFORMATION_SCHEMA.TABLES 
         WHERE TABLE_NAME = N'TableName'""")
  
  def checkTableExists(cnxn, TableName):
      cursor = cnxn.cursor()
      cursor.execute("""
          SELECT COUNT(*)
      FROM information_schema.tables
      WHERE TABLE_NAME = '{0}'
      """.format(TableName.replace('\'', '\'\'')))
      if cursor.fetchone()[0] == 1:
          cursor.close()
          return True
  
      cursor.close()
      return False
  
  if checkTableExists == True:
      print ("already")
  elif checkTableExists == False:
      print ("No")
  </code></pre>
  
  <p>But there is nothing happen, can anyone help me on this?
  I am using Micrsoft SQL Server Management Studio 2014 Express version.
  The code will be run in Python.
  Thank you    </p>