zoukankan      html  css  js  c++  java
  • sqlserver2008 删除指定表

    declare @tbname varchar(50),
    @sql nvarchar(1000)
                                          --定义变量@tbname,@sql,@j
    declare tbroy cursor for
    select name from sysobjects as a
    where xtype= 'u'
    and SUBSTRING(name,0,3)='PM'
    order by name  
                                                       --定义游标,sysobjects为系统表,xtype= 'u'表示是用户表
    open tbroy                                                          --填充游标
    fetch next from tbroy into @tbname                                  --提取游标
    while @@fetch_status=0
    begin
    --select @sql='drop table '+@tbname
    --exec sp_executesql @sql
    exec ('drop table '+@tbname)
    fetch next from tbroy into @tbname
    end                                                                  --while到and的内容看不懂,希望大家帮忙

    close tbroy                                                          --关闭游标
    deallocate tbroy       

  • 相关阅读:
    OJ 之 FATE
    hdu 1701 (Binary Tree Traversals)(二叉树前序中序推后序)
    POJ 1789 Truck History
    数据结构之 普利姆算法总结
    HDU OJ 2159 FATE
    The Great Pan
    2014年的暑假ACM之旅!
    0-1背包问题
    中国剩余定理的解释!
    POJ 1183 反正切函数的应用
  • 原文地址:https://www.cnblogs.com/davicelee/p/2264124.html
Copyright © 2011-2022 走看看