locked
filename without directory RRS feed

  • Question

  • how to insert the exact  filename to the database without getting the full directory like c://something/something/filename  into the column 'Filename'

     

     

    waitng for reply

    Tuesday, August 31, 2010 6:09 AM

Answers

  • Hi,

    Transact-SQL Statement could be:

    declare @filename varchar(8000)
    set @filename = 'C:\Program Files\Microsoft Visual Studio 10.0\resist.txt'
    select right(@filename, charindex('\', reverse(@filename)) - 1)
    

    And if your path is really using / instead of \ (which is not windows like then), then you have to replace that char of course.

    I hope that was now, what you are looking for.

    With kind regards,

    Konrad

    • Marked as answer by Kalman Toth Tuesday, September 7, 2010 5:28 AM
    Tuesday, August 31, 2010 6:29 AM
  • Hmm ... we are inside the TRANSACT-SQL Forum here and not the the Biztalk forum. I can be wrong one time, but when I recognize it, you can be sure, that I checke dit correctly :)

    And what do you mean with just teh filename? if you check my T-SQL example:

    From 'C:\Program Files\Microsoft Visual Studio 10.0\resist.txt' you will get the "resist.txt". That is the filename in my eyes. Or do you mean without the extension?

    So far I still believe that
    select right(@filename, charindex('\', reverse(@filename)) - 1)
    should be the solution in T-SQL to your question.

    With kind regards,

    Konrad

     

    • Proposed as answer by dbp2784 Tuesday, August 31, 2010 12:48 PM
    • Marked as answer by Kalman Toth Tuesday, September 7, 2010 5:28 AM
    Tuesday, August 31, 2010 12:38 PM

All replies

  • Hi,

    I understood that you just want to get the Filename of a filename with full path. So maybe you are looking for Path.GetFileName(filename):
    http://msdn.microsoft.com/en-us/library/system.io.path.getfilename.aspx

    With kind regards,

    Konrad

    Edit: Sorry. Was mixed up with threads in C# related forums. Sorry for that.

     

    Tuesday, August 31, 2010 6:22 AM
  • Hi,

    Transact-SQL Statement could be:

    declare @filename varchar(8000)
    set @filename = 'C:\Program Files\Microsoft Visual Studio 10.0\resist.txt'
    select right(@filename, charindex('\', reverse(@filename)) - 1)
    

    And if your path is really using / instead of \ (which is not windows like then), then you have to replace that char of course.

    I hope that was now, what you are looking for.

    With kind regards,

    Konrad

    • Marked as answer by Kalman Toth Tuesday, September 7, 2010 5:28 AM
    Tuesday, August 31, 2010 6:29 AM
  • i have asked the question in Biztalk forums 

    Any way thanks for your suggestion

    Tuesday, August 31, 2010 6:44 AM
  • i am looking for filename without full path means just filename
    Tuesday, August 31, 2010 8:32 AM
  • Hmm ... we are inside the TRANSACT-SQL Forum here and not the the Biztalk forum. I can be wrong one time, but when I recognize it, you can be sure, that I checke dit correctly :)

    And what do you mean with just teh filename? if you check my T-SQL example:

    From 'C:\Program Files\Microsoft Visual Studio 10.0\resist.txt' you will get the "resist.txt". That is the filename in my eyes. Or do you mean without the extension?

    So far I still believe that
    select right(@filename, charindex('\', reverse(@filename)) - 1)
    should be the solution in T-SQL to your question.

    With kind regards,

    Konrad

     

    • Proposed as answer by dbp2784 Tuesday, August 31, 2010 12:48 PM
    • Marked as answer by Kalman Toth Tuesday, September 7, 2010 5:28 AM
    Tuesday, August 31, 2010 12:38 PM