zoukankan      html  css  js  c++  java
  • 在sql中处理文件的操作

    myfavorite

    DECLARE @Path nvarchar(200)
    SET @Path = 'C:\Inetpub\wwwroot\kaoq\txt\'
    IF RIGHT(@Path1<> '\'
        
    SET @Path = @Path + '\'
    IF OBJECT_ID('tempdb..#'IS NOT NULL
        
    DROP TABLE #
    CREATE TABLE #
    (
        id 
    int IDENTITY,
        directory 
    nvarchar(260),
        depth 
    int,
        IsFile 
    bit
    )
    INSERT # EXEC master.dbo.xp_dirtree @path = @path,@depth = 0,@file = 1


    declare @strPath varchar(200)
    declare cur_file cursor for select 'C:\Inetpub\wwwroot\kaoq\txt\' + directory from # order by directory
    open cur_file
    fetch next from cur_file into @strPath
    while @@fetch_status=0 
        
    begin
            
    declare @o int,@f int,@t int,@ret int
            
    declare @card8 varchar(1000)
            
    declare @date8 varchar(1000)
            
    declare @time8 varchar(1000)


            
    exec @ret=sp_OACreate 'Scripting.FileSystemObject',@o out
            
    exec @ret=sp_oamethod @o,'OpenTextFile',@f out,@strPath,1
            
    exec @ret=sp_oamethod @f,'readline',@card8 out
            
    exec @ret=sp_oamethod @f,'readline',@date8 out
            
    exec @ret=sp_oamethod @f,'readline',@time8 out
            
    --'''''''处理数据
            exec @ret=sp_OADestroy @f
            
    exec @ret=sp_OAMethod @o'DeleteFile'NULL@strPath
            
    exec @ret = sp_OADestroy @o

            
    fetch next from cur_file into @strpath
        
    end
    close cur_file
    deallocate cur_file
  • 相关阅读:
    如何唤醒一个处于阻塞状态下的线程
    如何终止一个线程
    网络编程基础_5.1聊天室-客户端
    网络编程基础_4.2TCP-客户端
    网络编程基础_4.1TCP_服务端
    网络编程基础_3.APC队列
    网络编程基础_2.等待事件
    网络编程基础_1.等待句柄
    Window提高_3.1练习_双进程守护
    Windows提高_2.3第三部分:内核区同步
  • 原文地址:https://www.cnblogs.com/MyFavorite/p/923003.html
Copyright © 2011-2022 走看看