drop tables from sql server using batch file

marina ustinova 1 Reputation point
2022-11-24T10:35:50.293+00:00

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.
302 questions
{count} votes

1 answer

Sort by: Most helpful
  1. Bas Pruijn 946 Reputation points
    2022-11-24T13:37:20.23+00:00

    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