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
  • 相关阅读:
    js 遍历数组对象求和
    小程序使用微信地址or小程序跳转设置页
    css内容渐入效果实现
    flutter实现文字超出最大宽度显示省略号
    flutter查看安全码SHA1
    Uncaught (in promise)
    小程序iphone蒙层滚动穿透
    map中使用箭头函数遇到的坑
    骨架屏css样式
    javascript(js)反转字符串
  • 原文地址:https://www.cnblogs.com/MyFavorite/p/923003.html
Copyright © 2011-2022 走看看