All articles(网络文学目录) All Pictures(图片目录) All Softwares(软件目录)

 
有用的SQL语句(删除重复记录,收缩日志)_[SQL,Server教程]

Writer: 归海一刀 Article type: Programming skills(编程技巧) Time: 2014/2/1 0:21:52 Browse times: 452 Comment times: 0

有用的SQL语句(删除重复记录,收缩日志)_[SQL,Server教程]


Head photo

Go homepage
Upload pictures
Write articles

有用的SQL语句(删除重复记录,收缩日志)_[SQL Server教程]

删除重复记录,将TABLE_NAME中的不重复记录保存到#TABLE_NAME中

select distinct * into #table_name from table_name
delete from table_name
select * into table_name from #table_name
drop table #table_name

与此相关的是“select into”选项,可以在数据库属性
对话框中,勾起来此项,或者在Query Analyzer中执行
execute sp_dboption 'db_name','select into','true'
开启。默认值是关闭的。


*************************************
收缩事务日志(多次执行)

backup log register with NO_LOG
backup log register with TRUNCATE_ONLY
DBCC SHRINKDATABASE(register)

来源:网络





There are 0 records,
Comment:
Must be registered users to comment(必须是注册用户才能发表评论)

Disclaimer Privacy Policy About us Site Map
Copyright ©2011-
uuhomepage.com, Inc. All rights reserved.