Please help to get the data from 3rd to 4th under score i.e 20200912175059319

  • organisationneyes.wsd.md_1_1_20200912175059319_a86d1d549e1cafcf.jpg

    from above string Please help to get the data from 3rd under score to 4th underscore  i.e like 20200912175059319

    Thank you for the help in advance

  • You can read THIS ARTICLE on Splitter functions by Jeff Moden.

    At the end of the article, you will find a link "The New Splitter Functions.zip" that will allow you to download the source code for DelimitedSplit8K.  Install this function, and use as follows

    /*
    Extract from a variable
    */
    DECLARE @FileName VARCHAR(255) = 'organisationneyes.wsd.md_1_1_20200912175059319_a86d1d549e1cafcf.jpg'

    SELECT [FileName] = @FileName, FileDateTime = splt.Item
    FROM dbo.DelimitedSplit8K(@FileName, '_') AS splt
    WHERE splt.ItemNumber = 4;
    /*
    Extract from a table
    */
    DECLARE @YourTable TABLE (ID INT IDENTITY(1,1) NOT NULL, FileName VARCHAR(255) NOT NULL);

    INSERT INTO @YourTable(FileName)
    VALUES ('organisationneyes.wsd.md_1_1_20200912175059319_a86d1d549e1cafcf.jpg')

    SELECT src.*, FileDateTime = splt.Item
    FROM @YourTable AS src
    CROSS APPLY dbo.DelimitedSplit8K(src.FileName, '_') AS splt
    WHERE splt.ItemNumber = 4;

Viewing 2 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic. Login to reply