Article ID: 317032 - Last Review: October 26, 2002 - Revision: 1.0 HOW TO: Change the Temp Database Location in SQL Server CE
This article was previously published under Q317032 On This PageSUMMARY
Microsoft SQL Server 2000 Windows CE Edition version 1.1 (SQL Server CE) creates a temporary database that it uses for storing temporary data such as:
Several SQL Server CE users have large databases that create large volumes of temporary data during synchronization. Large databases cause the SQL Server CE application to fail because of insufficient storage space on the default storage device for both the main database file and the temporary database file. The temporary database grows every time a sort operation occurs. A sort operation is not limited to but includes:
You can delete a temporary database whenever the operating system allows a deletion. If a file is open in SQL Server CE and SQL Server CE is using the file, the operating system disallows a deletion. By default, the operating system creates temporary database files in the Temp folder on the Windows CE device. SQL Server CE automatically deletes the temporary file after you successfully remove the SQL Server CE engine. However, an abnormal termination of a SQL Server CE application may leave files in the Temp folder. If files remain in the Temp folder, you must perform a periodic cleanup of the temporary files. Even if you move your user database (.sdf) file to a flash card (to store large databases), the temporary database files are created in the Temp folder. This creation of temporary files causes problems for customers who store large databases and perform intensive queries with sort operations. When the Server CE engine starts, it creates a temporary database. The first database operation that causes the SQL Server CE engine to start must include the location of the temporary database. This article outlines how you can change the temporary database location for SQL Server CE. Before you change the tempdb location in your code, you must apply the fix mentioned in the following Microsoft Knowledge Base article: 305349
(http://support.microsoft.com/kb/305349/EN-US/
)
FIX: SSCE:Temp File Directory Property Allows You to Change the Temp Database Location for SQL Server CE
How to Specify a Tempdb Location with ActiveX Data Objects for Microsoft Windows CE (ADOCE)Connection strings that contain a list of property values separated by semi-colons control the ADOCE operations. You can specify a temporary database location by adding the following sub-string to the end of the connection string:For ADOCE, you must include the temporary database location for the Connection.Open method. You can also specify the temporary database location in the source connect string for the Engine.CompactDatabase method. How to Specify a Tempdb Location for Remote Data Access and ReplicationRemote Data access (RDA) and Replication operations are controlled by connection strings that contain a list of property values separated by semi-colons. You can specify the temporary database location by adding the following sub-string to the end of the connection string:For RDA, you must include the temporary database location for all methods that use an OLEDBConnectionString property. This includes:
How to Specify a Tempdb Location for OLEDB OperationsOLEDB Operations that can accept properties in preparation for loading the SQL Server CE engine are:
The property name is: DBPROP_SSCE_TEMPFILE_DIRECTORY The property description is: "SSCE:Temp File Directory" The OLEDB property set for the tempfile directory is: DBPROP_SSCE_DBINIT The property value is: A string that can contain any valid path specification. Validation and Error HandlingThe client application verifies the temporary database location provided when the application passes the location to the operating system. SQL Server CE does not try to pre-verify the string. If you provide a UNC path, the success of the UNC path is up to the operating system. If the operating system can handle UNC paths and if the target directory is available, SQL Server CE succeeds at creating the temporary files in the specified location.If the directory name is invalid, or if the file name is invalid, or if the directory cannot be opened for writing, SQL Server CE fails with this error message:
SSCE_M_INVALIDTEMPPATH 25090
"The temp file folder location that you specified is not valid for this device"
Limitations of Specifying a Tempdb LocationThere is one temporary database per instance of the SQL Server CE engine. Therefore, a single copy of the temporary database is common for all connections to the same instance of the SQL Server CE engine.You can specify the temporary database location only once when SQL Server CE starts. After an instance is running and already has a tempdb, SQL Server CE ignores any attempts to choose another temporary database location. You must use the same temporary database location for every operation in your application that can trigger the database engine to load, even operations where the application writer is sure that the engine is already loaded. Use of the same temporary database location protects you against unexpected results from subsequent application restructuring, and from changes in the internal operation of SQL Server CE. You must not create applications that rely upon side-effects in the way that temporary databases are loaded. Microsoft reserves the right to change such incidental operation in future versions of SQL Server CE, both for single instances of the engine and for when there may be more than one instance of the engine, and is not responsible for maintaining compatibility with the current behavior. | Other Resources Other Support Sites
CommunityGet Help NowArticle Translations
|






Windows Live
Facebook
Twitter
Linkedin
Digg it
Yahoo
Delicious
StumbleUpon
Yammer
Reddit
Technorati
FriendFeed
Email

Back to the top
