블로그 이미지
LifeisSimple

calendar

1 2 3 4
5 6 7 8 9 10 11
12 13 14 15 16 17 18
19 20 21 22 23 24 25
26 27 28 29 30 31

Notice

'INFORMATION_SCHEMA'에 해당되는 글 1

  1. 2010.08.13 특정이름의 테이블/SP 등등 삭제
2010. 8. 13. 14:46 Brain Trainning/DataBase

/*

       Delete Del Table

*/

 

declare @tblName varchar(300)

declare curTblName cursor fast_forward for

       select TABLE_NAME

       from srvDB.INFORMATION_SCHEMA.tables where TABLE_NAME like '%삭제%'

open curTblName

fetch next from curTblName

       into @tblName

      

while @@FETCH_STATUS = 0

begin

       exec ('drop table ' + @tblName)

 

       fetch next from curTblName

             into @tblName

end

 

close curTblName

deallocate curTblName

 

 

/*

       Delete SP

*/

declare @prcName varchar(300)

 

declare curPrcName cursor fast_forward for

       select ROUTINE_NAME

             from srvDB.INFORMATION_SCHEMA.ROUTINES

       where ROUTINE_NAME like '%삭제%'

 

open curPrcName

 

fetch next from curPrcName

       into @prcName

      

while @@FETCH_STATUS = 0

begin

       exec ('drop proc ' + @prcName)

 

       fetch next from curPrcName

             into @prcName

end

 

close curPrcName

deallocate curPrcName

posted by LifeisSimple
prev 1 next