Home Forums SQL Server 2005 Development Pulling Filename from Windows directory into table RE: Pulling Filename from Windows directory into table

  • brianparow (9/20/2010)


    Nevermind;

    I figured out how to get rid of the trailing spaces within my batch file...

    Hi Jeff,

    That works great. The only problem I'm having with this is that the results seem to have a lot of trailing spaces in it.

    I tried to edit the following portion of your query but they are still showing up:

    SELECT rtrim(FileName) FROM #FileList WHERE Extension = '.txt' AND IsFile = 1

    EXCEPT

    SELECT rtrim(FileName) FROM #FileList WHERE Extension = '.pdf' AND IsFile = 1

    I'm sending the results of this to a text file that is referenced in a batch file to trigger a conversion and the trailing spaces are killing it.

    Also how difficult would it be to add the .txt extension back to the filename after checking. I tried to add Extension back in to the select but it says it needs to be in both. When adding it to both it obviously breaks the check from happening.

    Use the FullFileName in the SELECT list. It has filename and extension. Leave the WHERE clause as it is.

    --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)