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

  • 相关阅读:
    2.27
    string.Format("{0,-50}", "qqqqqqqqqqqq")
    dataGridView
    dataGridView添加列行
    设置拖拽事件,获取拖拽内容
    ,鼠标右键,将ListView的内容存入剪贴板
    winform ListView点击行表头,排序
    Aes加密解密
    C#get ,post HttpClient
    将json格式的string转化为对象
  • 原文地址:https://www.cnblogs.com/mjgb/p/2474208.html
Copyright © 2011-2022 走看看