Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- DECLARE @cutoffDate datetime = CONVERT(DATETIME, DATEADD(YEAR,-1,GETDATE()), 112)
- SELECT 'DROP TABLE "' + TABLE_NAME + '"' AS 'Command'
- FROM INFORMATION_SCHEMA.TABLES
- WHERE (TABLE_NAME LIKE 'tableA%' OR TABLE_NAME LIKE 'tableB%')
- AND (CONVERT(DATETIME, SUBSTRING(TABLE_NAME, 7, 8), 112) < @cutoffDate)
- ORDER BY Command DESC
- SELECT CONVERT(DATETIME, SUBSTRING('tableA20110305', 7, 8), 112)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement