F
F
fortran2015-12-29 17:18:30
Database
fortran, 2015-12-29 17:18:30

How to implement a script for deleting empty tables in MS SQL database?

Actually there is a database in which there are more than 300 tables. The script creates new ones.
After a certain time, it is necessary to go through and remove the empty ones. It is possible to make on T-SQL, but it would be desirable to implement one request (nested). If you googled badly - poke your nose. Thank you.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
D
Dmitry Kovalsky, 2015-12-29
@dmitryKovalskiy

You can check it out . Pass inside the name of the database and entity and delete if returned non-NULL. But I would understand why the hell tables are constantly created and deleted.

X
xmoonlight, 2015-12-29
@xmoonlight

The algorithm seems to be simple:
1. get a list of all tables from the database
2. filter out unnecessary ones by name (if required)
3. foreach through the list with count ... limit 1
Design as a trigger.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question