Advertisement
Guest User

Untitled

a guest
May 30th, 2016
60
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.40 KB | None | 0 0
  1. DECLARE @cutoffDate datetime = CONVERT(DATETIME, DATEADD(YEAR,-1,GETDATE()), 112)
  2.  
  3. SELECT 'DROP TABLE "' + TABLE_NAME + '"' AS 'Command'
  4. FROM INFORMATION_SCHEMA.TABLES
  5. WHERE (TABLE_NAME LIKE 'tableA%' OR TABLE_NAME LIKE 'tableB%')
  6. AND (CONVERT(DATETIME, SUBSTRING(TABLE_NAME, 7, 8), 112) < @cutoffDate)
  7. ORDER BY Command DESC
  8.  
  9. SELECT CONVERT(DATETIME, SUBSTRING('tableA20110305', 7, 8), 112)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement