1.查询指定数据库中所有表名

  use YOURDATABASENAME//你的数据库名称

  SELECT * FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_TYPE = 'BASE TABLE'

2.清空所有表数据

  exec   sp_msforeachtable   @command1='truncate   table   ?',  
  @whereand='   and   objectproperty(o.id,''TableHasForeignRef'')=0'  
  exec   sp_msforeachtable   @command1='delete   from   ?',  
  @whereand='   and   objectproperty(o.id,''tablehasforeignref'')=1'

3.恢复数据库 restore database bworlddealergroup from disk='C:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\Backup\BWorldDealerGroup' with replace,move 'BWorldDealerTest' to 'C:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\Data\BWorldDealerGroup.mdf', move 'BWorldDealerTest_log' to 'C:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\Data\BWorldDealerGroup_log.ldf'

posted on 2011-07-27 11:34  baby_tao  阅读(201)  评论(0编辑  收藏  举报