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
  • 相关阅读:
    任务管理器程序——让任务更好的完成
    任务管理器——让你的任务更好的完成 助力中考
    Re:萌娘百科上的黑幕实现
    404 页面不存在
    JavaScript中,数组和对象的遍历方法总结
    JavaScript Math方法的基本使用
    html css二级导航栏
    css常用元素通用样式表
    web前端sprite,精灵图,雪碧图
    个人总结
  • 原文地址:https://www.cnblogs.com/MyFavorite/p/923003.html
Copyright © 2011-2022 走看看