EXEC sp_MSforeachtable 
@whereand='and exists(select * from sysobjects where xtype=''u'' and status>=0)',
@command1='drop table  ?'

解决方案 »

  1.   

    如果数据库表间没有关系,则直接删除:
    declare @sql varchar(8000)
    set @sql=''
    select @sql=@sql+char(13)+'go'+char(13)+'delete from '+name
     from sysobjects where xtype='U' and name<>'dtproperties'
    exec(@sql)否则删除语句必须要有顺序
      

  2.   

    EXEC sp_MSforeachtable 
    @whereand='and exists(select * from sysobjects where xtype=''u'' and status>=0)',
    @command1='delete from  ?'
      

  3.   

    pbsql(风云):
    你能解释一下吗?我存储过程一点不懂,我要删除数据,不删除表?
      

  4.   

    就是写一些删除数据的SQL语句,如下:
    go
    delete from t1
    go
    delete from t2
    go
    delete from t3
    ....然后执行
      

  5.   

    from sysobjects where xtype='U' and name<>'dtproperties',这是什么意思?