【SQLSERVER】清空数据库所有表数据
2013-11-15 10:05
330 查看
[sql] view plaincopyprint? -------清空数据库所有表数据 exec sp_MSforeachtable "truncate table ?" ----查询数据库所有表名 select [name] from sysobjects where type='u' --- 游标 清空所有表数据 declare @tableName varchar(50) declare @Sql nvarchar(200) declare @count int declare TBCursor cursor for select [name] from sysobjects where type='u' open TBCursor fetch next from TBCursor into @tableName while @@fetch_status=0 begin set @Sql=N'delete from '+ @tableName exec sp_executesql @Sql --过程 sp_executesql,第 1 行 过程需要类型为 'ntext/nchar/nvarchar' 的参数 '@statement'。 fetch next from TBCursor into @tableName end close TBCursor deallocate TBCursor -----向 IntKey 表 插入数据库表名 insert into IntKey(KeyName) select [name] from sysobjects where type='u'
相关文章推荐
- SQLServer清空数据库中所有表的数据
- 【Sqlserver清空数据库中所有表数据】
- 使用SQL语句清空数据库所有表的数据
- 清空某个数据库中所有表的数据
- 使用SQL语句清空数据库所有表的数据
- VC sqlserver中获取数据库所有表、字段名、记录数据
- SQL 清空数据库的所有表数据
- 使用SQL语句清空数据库所有表的数据
- 使用SQL语句清空数据库所有表的数据
- MSSQL清空当前数据库中所有用户表的数据,重置标识列
- SQL Server 自增字段重置与清空数据库中所有表数据的方法
- 清空数据库里面的所有数据
- 使用SQL语句清空数据库所有表的数据
- 清空一个数据库中所有数据
- (SqlServer)批量清理指定数据库中所有数据
- 使用SQL语句清空数据库所有表的数据
- 使用SQL语句清空数据库所有表的数据(转)
- SQLServer遍历数据库所有表及统计表数据总数
- 清空数据库所有表数据
- SQL Server 如何清空数据库所有表数据