문제

I have a SQL server 2005. In that server I have 3 databases -> a,b,c.

If I want to delete tables

  1. Tables only from database "c".
  2. The table's name should start with "bkp"
  3. Table should be created one day before.
도움이 되었습니까?

해결책

Try this:

USE C
GO

SELECT
'DROP TABLE ' + name
FROM sys.tables
WHERE create_date >= '20101211'   -- substitute your date you're interested in
AND name like 'bkp%'

This will create as output a list of DROP TABLE:.... statement - copy those and paste them into a new SSMS window and execute those - and you're done!

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top