??????峤 发表于 2016-11-4 10:02:50

SQL Server 压缩日志及数据库文件大小

  
  
  
  以下是asp代码,当然里面都是SQL语句,直接就可以了、
  <%
conn.execute("delete from info where tid=12")  '删除SQL数据
  '下面的是执行数据库文件和日志文件压缩  tbname是数据库名字
tbname="newtianbo"
conn.execute("dump transaction "&tbname&" with no_log")  '清空日志
conn.execute("backup log "&tbname&" with no_log") '截断事务日志
conn.execute("dbcc shrinkdatabase("&tbname&")")  '压缩数据库
conn.execute("select * from sysfiles DBCC SHRINKFILE(1)") '压缩指定数据文件
conn.execute("EXEC sp_dboption "&tbname&", 'autoshrink', 'TRUE'")  '自动压缩
%> 
页: [1]
查看完整版本: SQL Server 压缩日志及数据库文件大小