讲解删除SQL Server日志的具体方法
begin
if isnull(@bkfname,讲解具体)=

set @bkfname=@dbname+_+convert(varchar,getdate(),112)
+replace(convert(varchar,getdate(),108),:,)
select 提示信息=备份数据库到SQL 默认备份目录,备份文件名:+@bkfname
exec(backup database [+@dbname+] to disk=+@bkfname+)
end
--进行分离处理
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
pen 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
--附加数据库
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
1.2.3.4.5.6.7.8.9.10.11.12.13.14.15.16.17.18.19.20.21.22.23.24.25.26.27.28.29.30.31.32.33.34.35.36.37.38.39.40.41.42.43.44.45.46.47.48.49.50.51.52.53.54.55.56.57.58.59.60.61.62.63.64.65.66.67.68.69.70.71.72.73.74.75.76.77.78.79.80.81.82.83.84.85.86.87.88.89.90.91.92.93.94.95.96.97.98.99.100.101.102.103.104.105.106.107.108.109.110.111.112.113.114.115.116.117.