当前位置: 代码迷 >> Sybase >> sybase去掉当前用户的全部表的存储过程
  详细解决方案

sybase去掉当前用户的全部表的存储过程

热度:958   发布时间:2016-05-05 09:15:37.0
sybase去掉当前用户的所有表的存储过程
CREATE PROCEDURE sp_drop_tbl
AS
BEGIN
    DECLARE @tblname varchar(80)
    DECLARE @dropsql varchar(100)
    DECLARE cur1 CURSOR FOR
        SELECT name FROM dbo.sysobjects WHERE  type = 'U'
    OPEN cur1
    FETCH cur1 INTO @tblname

    WHILE (@@SQLSTATUS = 0)
    BEGIN
        SELECT @dropsql = "DROP TABLE " + @tblname
        EXEC (@dropsql)
        FETCH cur1 INTO @tblname
    END

    CLOSE cur1
    DEALLOCATE cursor cur1
END



然后 exec sp_drop_tbl