zoukankan      html  css  js  c++  java
  • SQL Get Files Under folder

    --go
    --create function fn_split(@str nvarchar(4000), @delimiter nvarchar(1))
    --returns @tempData table (slice nvarchar(4000))
    --as
    --begin

    --declare @index int
    --declare @slice nvarchar(4000)

    --if LEN(@str)<1 or @str is null return

    --set @index=charindex(@delimiter,@str)

    --while(@index<>0)
    --begin
    --set @slice=substring(@str,1,@index-1)
    --insert @tempData (slice) values (@slice)
    --set @str=substring(@str,@index+1,len(@str))
    --set @index=charindex(@delimiter,@str)
    --end

    --if len(@str)>0 insert @tempData(slice) values (@str)

    --return
    --end

    --go

    --go
    --create function fn_getLast(@str nvarchar(4000),@delimiter nvarchar(1))
    --returns nvarchar(4000)
    --as
    --begin
    --declare @r nvarchar(4000)
    --select @r =slice from dbo.fn_split(@str,@delimiter)
    --return @r
    --end
    --go

    --GO
    -- To allow advanced options to be changed.
    --EXEC sp_configure 'show advanced options', 1
    --GO
    ---- To update the currently configured value for advanced options.
    --RECONFIGURE
    --GO
    ---- To enable the feature.
    --EXEC sp_configure 'xp_cmdshell', 1
    --GO
    ---- To update the currently configured value for this feature.
    --RECONFIGURE
    --GO

    create table #filePath(FilePath varchar(300))
    declare @folder varchar(300)
    declare @return int
    set @folder='dir your folder'
    insert #filePath exec @return =master.dbo.xp_cmdshell @folder
    select dbo.fn_getLast(FilePath ,' ')
    from #filePath
    where FilePath like '%.sql'
    drop table #filePath

  • 相关阅读:
    多进程编程
    Python 的下载安装
    cnBlogs windows LIves Writes 安装
    第四章网页文字编排设计
    第三章网页图形图像设计
    第二章网页创意设计思维和方法
    1.3-1.4网页设计的定位和流程
    1.2网页设计的构成要素和特性
    网页编辑常用快捷方式+学习技巧+网站开发流程
    css选择器2——伪类选择器
  • 原文地址:https://www.cnblogs.com/mjgb/p/2474208.html
Copyright © 2011-2022 走看看