Results 1 to 5 of 5

Thread: How to get the a particular string

  1. #1
    Join Date
    Oct 2010
    Posts
    6

    Question How to get the a particular string

    Hi,

    How can I get the file name in a location?

    for eg : In the path E:\apple\New Folder\pics\apple.txt , i need to get the value as just 'apple.txt'

    this is just a simple example i have given. But the location is the DB has special characters as well.. such as '::' etc.

    Please help me.

  2. #2
    Join Date
    Sep 2002
    Posts
    5,938
    You store those info in db table? Can use 'select col from table where col like ...' if so.

  3. #3
    Join Date
    Oct 2010
    Posts
    6
    the values stored as the complete path. I just want to take the filename.
    If "E:\apple\New Folder\pics\apple.txt" is the value in the DB, I want to get just "apple" from it.

  4. #4
    Join Date
    Sep 2002
    Posts
    5,938
    Can use substring function to get that.

  5. #5
    Join Date
    Oct 2010
    Posts
    6
    Thats fine. I have tried and I got the results. But, it works for a specific length only. I wanted to get the filenames for differnet paths of different lengths.

    Select substring(PATH,charindex('\',PATH)+1,len(PATH))
    Result : apple\New Folder\pics\apple.txt

    I tried the above one but it returns the values from the first '\' onwards.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •