select query

  • sorry

  • Hi,

    try this

    create table #temp

    (

    text1 varchar(100)

    )

    insert into #temp

    select '\VOL003\TEXT\0001\11400034_00000.txt'

    union all

    select '\VOL003\TEXT\0001\114000305_00000.txt'

    union all

    select '\VOL003\TEXT\0001\1140000036_00001.txt'

    select replace(text1,'\VOL003\TEXT\0001\','') from #temp

    Result

    11400034_00000.txt

    114000305_00000.txt

    1140000036_00001.txt

    ARUN SAS

  • Since the original poster deleted his post, I'm speculating (from the reply post) that he wanted to get just the file name from a full path filename.

    A slightly better way to do this, in that this is not dependent on knowing the path in the first place, would be:

    select reverse(left(reverse(text1), CharIndex('\', reverse(text1)) - 1))

    from #temp

    Wayne
    Microsoft Certified Master: SQL Server 2008
    Author - SQL Server T-SQL Recipes


    If you can't explain to another person how the code that you're copying from the internet works, then DON'T USE IT on a production system! After all, you will be the one supporting it!
    Links:
    For better assistance in answering your questions
    Performance Problems
    Common date/time routines
    Understanding and Using APPLY Part 1 & Part 2

  • mjarsaniya (7/4/2009)


    sorry

    May we ask why you felt compelled to delete the text of your post?

  • mjarsaniya (7/4/2009)


    sorry

    --Jeff Moden


    RBAR is pronounced "ree-bar" and is a "Modenism" for Row-By-Agonizing-Row.
    First step towards the paradigm shift of writing Set Based code:
    ________Stop thinking about what you want to do to a ROW... think, instead, of what you want to do to a COLUMN.

    Change is inevitable... Change for the better is not.


    Helpful Links:
    How to post code problems
    How to Post Performance Problems
    Create a Tally Function (fnTally)

Viewing 5 posts - 1 through 4 (of 4 total)

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