There are times as a developer that you will want to be able to delete all the data from a database as efficiently as possible. Unfortunately, doing so may not be as easy as it seems.
I needed this capability on a recent consulting project to build a dashboard management reporting system for a very large medical database on a server with a slow DSL connection.
SELECT 'TRUNCATE TABLE ' +
['+ TABLE_CATALOG + '].['+ TABLE_SCHEMA + '].['+ TABLE_NAME + ']'
WHERE Table_Type = 'BASE TABLE'
ORDER by TABLE_NAME