免费视频淫片aa毛片_日韩高清在线亚洲专区vr_日韩大片免费观看视频播放_亚洲欧美国产精品完整版

打開(kāi)APP
userphoto
未登錄

開(kāi)通VIP,暢享免費(fèi)電子書(shū)等14項(xiàng)超值服

開(kāi)通VIP
如何在SQL SERVER 2000中刪除系統(tǒng)文件?

如何在SQL SERVER 2000中刪除系統(tǒng)文件?

[日期:2005-07-08]來(lái)源:CSDN  作者:[字體: ]

    /*****************************************************************************************************************

      在SQL Server 2000的開(kāi)發(fā)過(guò)程中有時(shí)會(huì)遇到要判斷和刪除系統(tǒng)級(jí)別的一些文件,這是通過(guò)SQL Server2000提供的一些系統(tǒng)函數(shù)可以非常方便的完成相應(yīng)的功能.下面是我寫(xiě)的一個(gè)實(shí)列:

Author:黃山光明頂

mail:leimin@jxfw.com

version:1.0.0

date:2004-1-30

(如需轉(zhuǎn)載,請(qǐng)注明出處!)

*********************************************************************************************************/
if exists (select * from sysobjects where id =
object_id(‘dbo.usp_DeleteFile‘) and sysstat & 0xf = 4)
 drop procedure usp_DeleteFile
GO
CREATE PROCEDURE usp_DeleteFile
 @filename varchar(255),
 @path     varchar(1024)
AS
BEGIN


 DECLARE @rc   int
 Declare @space_num int
 Declare @debug  int
 Declare @tempPath varchar(1024)
 Declare @tempdel varchar(1024)

 Select @rc=0
 Select @space_num=0

 Select @debug=0

 Select @tempPath=‘‘
 Select @tempdel=‘‘
 set nocount ON


/***************************************************************************
***********
  * Check whether @filename is null

****************************************************************************
**********/
 if  @filename is null
 begin
  PRINT ‘Please input file name‘
  select @rc=-90001
  return @rc
 end


/***************************************************************************
***********
  * Check whether @path is null

****************************************************************************
**********/
 if  @path is null
 begin
  PRINT ‘Please input delete file directory(exclude space)‘
  select @rc=-90002
  return @rc
 end


/***************************************************************************
***********
  * Check whether @path  includes space
  * if the OS is windows 2000 ,please confirm the path not includes space!!

****************************************************************************
**********/
 select @space_num=charindex(‘ ‘,@path)
 if  @space_num>0
 begin
  while charindex(‘ ‘,@path)>0
  begin
   select @tempPath=@tempPath+left(@path,charindex(‘ ‘,@path))
   select @path=ltrim(right(@path,len(@path)-charindex(‘ ‘,@path)))
  end

  select @temppath=@temppath+@path
  select
@temppath=stuff(replace(@temppath,‘\‘,‘"\"‘)+‘"‘,1,3,left(@temppath,2))+‘\‘+
@filename

  if @debug=1
  begin
   print @temppath
  end


 end

 SELECT @temppath=@path+‘\‘+@filename

 if @debug=1
  BEGIN
   print @temppath
  END


/***************************************************************************
***********
  * Create temp table to records file information

****************************************************************************
**********/
 Create table #fileexists(doesexist smallint,fileindir smallint,direxist
smallint)
 if @rc=0
 begin

  insert into #fileexists exec master..xp_fileexist @temppath
  if exists (select 1 from #fileexists where #fileexists.doesexist=1)
   begin
    select @tempdel=‘del ‘+@temppath
     if @debug=1
      BEGIN
       print @tempdel
      END
    exec  @rc=master..xp_cmdshell @tempdel,no_output
    if @rc<>0
     begin
         print ‘Deleting file faile,May be file in useing!‘
         drop table #fileexists
         select @rc=-90003
         return @rc
     end
    else
     begin
         print ‘Deleting file sucessfully!‘
     end

   end
  else
   begin
    print ‘Please check the directory and filename.the input file not
exist!‘
   end

 end

        drop table #fileexists
 return @rc
END
go
exec usp_DeleteFile ‘test.txt‘,‘c:\temp‘

本站僅提供存儲(chǔ)服務(wù),所有內(nèi)容均由用戶(hù)發(fā)布,如發(fā)現(xiàn)有害或侵權(quán)內(nèi)容,請(qǐng)點(diǎn)擊舉報(bào)。
打開(kāi)APP,閱讀全文并永久保存 查看更多類(lèi)似文章
猜你喜歡
類(lèi)似文章
在 SQL Server 中從完整路徑提取文件名(sql 玩轉(zhuǎn)文件路徑)
SQL SERVER2000數(shù)據(jù)庫(kù)備份和恢復(fù)存儲(chǔ)過(guò)程(加強(qiáng)版本)
Simple script to backup all SQL Server databa...
jre autoinstall
linux刪除的文件如何恢復(fù)?
sql server獲取查詢(xún)結(jié)果逗號(hào)前面部分的內(nèi)容
更多類(lèi)似文章 >>
生活服務(wù)
分享 收藏 導(dǎo)長(zhǎng)圖 關(guān)注 下載文章
綁定賬號(hào)成功
后續(xù)可登錄賬號(hào)暢享VIP特權(quán)!
如果VIP功能使用有故障,
可點(diǎn)擊這里聯(lián)系客服!

聯(lián)系客服