Created
November 9, 2020 09:05
-
-
Save shammelburg/9a68c4dc37fa5cc66e93cbd19ca2e3c2 to your computer and use it in GitHub Desktop.
Truncate all tables in Azure SQL Database
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
DECLARE @SQL varchar(max) | |
SET @SQL = (SELECT ' TRUNCATE TABLE [' + TABLE_SCHEMA +'].['+ TABLE_NAME + '];' | |
FROM INFORMATION_SCHEMA.TABLES | |
ORDER BY TABLE_SCHEMA DESC | |
FOR XML PATH('')) | |
-- Print Statement | |
-- SELECT @SQL | |
-- Execute command | |
-- EXEC (@SQL) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment