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       

  • 相关阅读:
    面向对象案例
    0429面向对象3.0
    Linux系统常用命令以及常见问题的解决方法
    VS2010查看源码对应的汇编语言
    【学习笔记】python
    Linux环境配置错误记录
    【学习笔记】TensorFlow
    git基本操作
    位操作的个人总结
    Java字符串拼接
  • 原文地址:https://www.cnblogs.com/davicelee/p/2264124.html
Copyright © 2011-2022 走看看