I am trying to drop 200 tables from my database and save the sql statements to 1 .sql file so they can be run in one go on each copy of the database.
I would like to use a separate drop table statement for each table so I can easily reference what line any errors appear on.
I have tried running a query in the following format
DROP TABLE schema.tablename GO DROP TABLE schema.tablename GO DROP TABLE schema.tablename GO
When I execute the query, I get
Incorrect syntax near 'GO'.
For each line.
What is the proper way of doing this that will still allow me to easily locate errors on the tables that are unable to be dropped?
Advertisement
Answer
The GO has to be on a separate line, or use a semi-colon
DROP TABLE schema.tablename GO DROP TABLE schema.tablename;