日韩天天综合网_野战两个奶头被亲到高潮_亚洲日韩欧美精品综合_av女人天堂污污污_视频一区**字幕无弹窗_国产亚洲欧美小视频_国内性爱精品在线免费视频_国产一级电影在线播放_日韩欧美内地福利_亚洲一二三不卡片区

刪除SQL Server日志的方法(4)_Mssql數(shù)據(jù)庫(kù)教程

編輯Tag賺U幣
教程Tag:暫無(wú)Tag,歡迎添加,賺取U幣!

推薦:解讀SQL存儲(chǔ)過程入門級(jí)教程
1.SQL存儲(chǔ)過程概述 在大型數(shù)據(jù)庫(kù)系統(tǒng)中,存儲(chǔ)過程和觸發(fā)器具有很重要的作用。無(wú)論是存儲(chǔ)過程還是觸發(fā)器,都是SQL語(yǔ)句和流程控制語(yǔ)句的集合。就本質(zhì)而言,觸發(fā)器也是一種存儲(chǔ)過程。存儲(chǔ)過程在運(yùn)算時(shí)生成執(zhí)行方式,所以,以后對(duì)其再運(yùn)行時(shí)其執(zhí)行速度很快。SQLSe


--5.分離數(shù)據(jù)庫(kù) 

if @bkdatabase=1 

begin 

if isnull(@bkfname,’’)=’’ 

set @bkfname=@dbname+’_’+convert(varchar,getdate(),112) 

+replace(convert(varchar,getdate(),108),’:’,’’) 

select 提示信息=’備份數(shù)據(jù)庫(kù)到SQL 默認(rèn)備份目錄,備份文件名:’+@bkfname 

exec(’backup database [’+@dbname+’] to disk=’’’+@bkfname+’’’’) 

end 


--進(jìn)行分離處理 

create table #t(fname nvarchar(260),type int) 

exec(’insert into #t select filename,type=status&0x40 from [’+@dbname+’]..sysfiles’) 

exec(’sp_detach_db ’’’+@dbname+’’’’) 


--刪除日志文件 

declare @fname nvarchar(260),@s varchar(8000) 

declare tb cursor local for select fname from #t where type=64 

open tb 

fetch next from tb into @fname 

while @@fetch_status=0 

begin 

set @s=’del "’+rtrim(@fname)+’"’ 

exec master..xp_cmdshell @s,no_output 

fetch next from tb into @fname 

end 

close tb 

deallocate tb 


--附加數(shù)據(jù)庫(kù) 

set @s=’’ 

declare tb cursor local for select fname from #t where type=0 

open tb 

fetch next from tb into @fname 

while @@fetch_status=0 

begin 

set @s=@s+’,’’’+rtrim(@fname)+’’’’ 

fetch next from tb into @fname 

end 

close tb 

deallocate tb 

exec(’sp_attach_single_file_db ’’’+@dbname+’’’’+@s) 

go 
 

分享:按指定排列順序獲取數(shù)據(jù)的sql語(yǔ)句
測(cè)試table create table table1 (id int,name char) insert into table1 select 1,'q' union all select 2,'r' union all select 3,'3' union all select 4,'5' 要求按指定的id順序(比如2,1,4,3)排列獲取table1的數(shù)據(jù) 方法1: 使用union all,但是有256條數(shù)據(jù)的

共4頁(yè)上一頁(yè)1234下一頁(yè)
來源:模板無(wú)憂//所屬分類:Mssql數(shù)據(jù)庫(kù)教程/更新時(shí)間:2010-04-05
相關(guān)Mssql數(shù)據(jù)庫(kù)教程