zoukankan      html  css  js  c++  java
  • 批量删除储存过程和表

    清空表数据

    select * from sysobjects where type='U' AND [name] LIKE 'wf[_]%'
    ORDER BY [NAME]

    declare tablecur cursor
        for
            select [name] from sysobjects where type='U'  AND [name] LIKE 'wf[_]%'
    declare @procname varchar(100)
    open tablecur
    fetch next from tablecur into @procname
    while(@@FETCH_STATUS = 0)
    begin  
        exec('TRUNCATE TABLE ' + @procname)  --本句被注释,使用时请取消

        print(@procname + '数据已被清空')
        fetch next from tablecur into @procname
    end
    close tablecur
    deallocate tablecur

    -------------------------------------------------------------

    删除储存过程

    select * from sysobjects where type='P' AND [name] LIKE 'x[_]%'
    ORDER BY [NAME]

    declare proccur cursor
        for
            select [name] from sysobjects where type='P'  AND [name] LIKE 'x[_]%'
    declare @procname varchar(100)
    open proccur
    fetch next from proccur into @procname
    while(@@FETCH_STATUS = 0)
    begin  
        exec('drop proc ' + @procname)  --本句被注释,使用时请取消

        print(@procname + '已被删除')
        fetch next from proccur into @procname
    end
    close proccur
    deallocate proccur

    ----------------------------------------------------------------------

    删除表

    select * from sysobjects where type='U' AND [name] LIKE 'wf[_]%'
    ORDER BY [NAME]

    declare tablecur cursor
        for
            select [name] from sysobjects where type='U'  AND [name] LIKE 'wf[_]%'
    declare @procname varchar(100)
    open tablecur
    fetch next from tablecur into @procname
    while(@@FETCH_STATUS = 0)
    begin  
        exec('drop table ' + @procname)  --本句被注释,使用时请取消

        print(@procname + '已被删除')
        fetch next from tablecur into @procname
    end
    close tablecur
    deallocate tablecur

  • 相关阅读:
    纳尼?不用码代码,就可回归主流程,一只海豚就可以做到
    教育产品-组件化视觉设计实践
    从整理看视觉设计(网易云课堂我的学习中心-微专业视觉优化)
    搜索意图识别浅析
    如何配置使用Dnsmasq
    如何实现最佳的跨平台游戏体验?Unity成亮解密实时渲染技术!
    PAT 1024. Palindromic Number
    PAT 1023. Have Fun with Numbers
    PAT 1022. Digital Library
    PAT 1021. Deepest Root
  • 原文地址:https://www.cnblogs.com/amylis_chen/p/2073986.html
Copyright © 2011-2022 走看看