Microsoft ODBC Driver 17 for SQL Server - Query Result TEMP Storage

Derek Lauro 1 Reputation point
2020-11-11T16:05:12.37+00:00

My question is simple. Is there a property of the Microsoft ODBC Driver 17 for SQL Server (or any version for that matter) to change where it stores the query results?

By default, this driver stores query result data into files under “%USERPROFILE%\AppData\Local\Temp". You can see this generating files as connections are opened and query results are gathered.

The problem is, due to a new behavior in Windows Server 2019, a user's %TEMP% folder is automatically deleted every 7 days. Not cleared out, deleted (and not recreated for some reason). Seems like an oversight from Microsoft, but here we are. This prevents the Microsoft ODBC Driver 17 for SQL Server from being able to provide query results to my application, and any application that relies on accessing %TEMP% no longer functions properly until the user account logs off and back on, or the server is restarted. This makes it very difficult to manage an application that needs to be running 24/7/365. In the article they provide a workaround to remove or delay this cleanup with a registry hack, but this would be difficult to roll out on a global scale for all of my clients.
Here is the article I am referencing: https://learn.microsoft.com/en-us/troubleshoot/windows-server/shell-experience/temp-folder-with-logon-session-id-deleted

So rather than relying on the unreliable Windows temp directory, I'm wondering if I can define my own query result temp directory, any ideas? I'm not seeing any properties of the ODBC to be able to do so.

Windows for business | Windows Server | User experience | Other
Developer technologies | Transact-SQL
SQL Server | Other
{count} votes

3 answers

Sort by: Most helpful
  1. m 4,276 Reputation points
    2020-11-12T02:25:55.5+00:00

    Hi @Derek Lauro ,

    Is there a property of the Microsoft ODBC Driver 17 for SQL Server (or any version for that matter) to change where it stores the query results?

    Yes. Do you want to change the default stored path to a new specific one? You can choose the 'Tracing' and then click 'Browse' change the default path to what you want and then click OK.
    39211-20201112changederiver17path2.jpg

    So rather than relying on the unreliable Windows temp directory, I'm wondering if I can define my own query result temp directory, any ideas?

    Same answer as the first question.

    BR,
    Mia


    If the answer is helpful, please click "Accept Answer" and upvote it.


  2. m 4,276 Reputation points
    2020-11-13T08:12:16.687+00:00

    Hi @Derek Lauro ,

    Please click "Start Tracing Now" and begin your tracing, and then check it again.
    39643-20201113begintracing.jpg

    BR,
    Mia


    If the answer is helpful, please click "Accept Answer" and upvote it.


  3. m 4,276 Reputation points
    2020-11-16T01:42:58.183+00:00

    Hi @Derek Lauro ,

    I'm not looking to log trace. See my screenshot - the tmp files that I highlighted in yellow are what I would like to have generate in a new directory.

    Yes. I know.
    I mean do you click "Start Tracing Now" lab when you begin collect the log?

    BR,
    Mia


    If the answer is helpful, please click "Accept Answer" and upvote it.

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.