drop tables from sql server using batch file

marina ustinova 1 Reputation point

Hi All
I am trying to create a batch file to be able to drop tables from the sql server. The list of table names to drop will be provided in the excel spreadsheet. Is there a way to write a code which can update the table names every time it's needed?
Thank you

Azure SQL Database
Azure Batch
Azure Batch
An Azure service that provides cloud-scale job scheduling and compute management.
320 questions
{count} votes

1 answer

Sort by: Most helpful
  1. Bas Pruijn 951 Reputation points

    Sure this can be done. There are plenty of options to achieve this:

    • Maybe the easiest way to achieve this, is to look at a logic app. This can read your excel natively (if it can access it) and then for each row in your excel execute a SQL statement on the database.
    • You could use an automation account where (using Powershell) you can execute T_SQL statements on your database. This requires some knowledge of both T-SQL and Powershell.
    • you can write an Azure function in a language you prefer (python, C#, Java, Powershell,...)

    The bigger question is however, why do you regularly need to remove tables from your database and why will the list of these tables be stored in an Excel sheet. I strongly believe that removing tables from a database should be a Database Administrator task and not a task executed by an Excel sheet.

    0 comments No comments