Skip to content

Instantly share code, notes, and snippets.

@jamescalam
Last active February 22, 2020 22:29
Show Gist options
  • Save jamescalam/45bc65ce23076fce36e1276ea98af241 to your computer and use it in GitHub Desktop.
Save jamescalam/45bc65ce23076fce36e1276ea98af241 to your computer and use it in GitHub Desktop.
def drop(self, tables):
# check if single or list
if isinstance(tables, str):
# if single string, convert to single item in list for for-loop
tables = [tables]
for table in tables:
# check for pre-existing table and delete if present
query = ("IF OBJECT_ID ('["+table+"]', 'U') IS NOT NULL "
"DROP TABLE ["+table+"]")
self.manual(query) # execute
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment