参照资料自己整理的,可能还有更好的办法,以后再做补充吧。
1.先用backup语句备份整个数据库
2.创建一个新的数据库,使用restore语句还原备份的数据库
3.清除新数据库中用户表的数据
附:
use 【型数据库名】
go
DECLARE cursor1 cursor for SELECT name FROM sysobjects where xtype='U'
OPEN cursor1
DECLARE @tablename varchar(100)
DECLARE @sSql varchar(max)
FETCH next from cursor1 into @tablename
WHILE @@fetch_status=0
begin
set @sSql='delete from '+@tablename
exec(@sSql)
FETCH next from cursor1 into @tablename
end
CLOSE cursor1
DEALLOCATE cursor1