# SQL Server Compact

> Mediated Wiki article. Canonical URL: https://mediated.wiki/source/SQL_Server_Compact
> Markdown URL: https://mediated.wiki/source/SQL_Server_Compact.md
> Source: https://en.wikipedia.org/wiki/SQL_Server_Compact
> Source revision: 1276198290
> License: Creative Commons Attribution-ShareAlike 4.0 International (https://creativecommons.org/licenses/by-sa/4.0/)

{{Short description|Microsoft relational database}}
'''Microsoft SQL Server Compact''' ('''SQL CE''') is a discontinued [relational database](/source/relational_database) produced by [Microsoft](/source/Microsoft) for applications that run on mobile devices and desktops. Prior to the introduction of the desktop platform, it was known as ''SQL Server for [Windows CE](/source/Windows_Embedded_Compact)'' and ''SQL Server Mobile Edition''.

It includes both 32-bit and 64-bit native support.<ref name="40Release"/> SQL CE targets occasionally connected applications and applications with an embedded database.<ref name="Datasheet">{{cite web | url = http://download.microsoft.com/download/7/f/c/7fc20778-4e2e-4944-b432-ed74b404e542/sqlservercompactdatasheet_final.doc | title = SQL Server 2005 Compact Edition Datasheet | access-date = 2007-07-03 | archive-url = https://web.archive.org/web/20070316004210/http://download.microsoft.com/download/7/f/c/7fc20778-4e2e-4944-b432-ed74b404e542/sqlservercompactdatasheet_final.doc | archive-date = 2007-03-16 | url-status = dead }}</ref> It is free to download and redistribute.<ref name="Datasheet"/> An [ODBC](/source/Open_Database_Connectivity) driver for SQL CE does not exist, nor is one planned. Native applications may use SQL CE via [OLE DB](/source/OLE_DB).

The latest, and last, release is SQL Server Compact 4.0.<ref name="40Release">{{cite web | url = https://cloudblogs.microsoft.com/sqlserver/2011/01/13/microsoft-sql-server-compact-4-0-is-available-for-download-and-use-with-webmatrix/ | title = Microsoft SQL Server Compact 4.0 is available for download and use with WebMatrix | date = 13 January 2011 | access-date = 2020-03-11}}</ref> In February 2013 SQL Server Compact Edition had been deprecated; no new versions or updates are planned, although Microsoft continued to support the product until July 2021.<ref name="LCSQLCE40"/>

== Overview ==
SQL Server Compact shares a common [API](/source/Application_Programming_Interface) with the other [Microsoft SQL Server](/source/Microsoft_SQL_Server) editions.<ref name="Lap1">{{cite web |url=http://www.devx.com/dotnet/Article/33049/0 |title=A Lap Around SQL Server 2005 Compact Edition |access-date=2005-07-03}}</ref> It also includes [ADO.NET](/source/ADO.NET) providers for data access using ADO.NET APIs, and built-in synchronization capabilities,<ref name="Datasheet"/> as well as support for [LINQ](/source/Language_Integrated_Query) and [Entity Framework](/source/Entity_Framework). Future releases will unify the synchronization capabilities with [Microsoft Synchronization Services](/source/Microsoft_Synchronization_Services).{{needs update|date=December 2023|reason=Did this happen? If not, it doesn't look like it ever will}}<ref name="JAD">{{cite web |url=http://www.ddj.com/dept/database/193402926 |title=SQL Server Everywhere: Just Another Database? |access-date=2007-07-03}}</ref> Unlike other editions of [Microsoft SQL Server](/source/Microsoft_SQL_Server), SQL CE runs in-process<ref name="JAD"/> with the application which is hosting it. It has a disk footprint of less than 2 [MB](/source/Megabyte) and a [memory footprint](/source/memory_footprint) of approximately 5 MB.<ref name="Datasheet"/> SQL CE is optimized for an architecture where all applications share the same memory pool.<ref name="New">{{cite web |url=https://technet.microsoft.com/en-us/library/ms172417.aspx |title=What's New (SQL Server Compact Edition) |access-date=2007-07-03}}</ref>
[Windows Store app](/source/Windows_Store_app)s for Windows 8 cannot use SQL Server Compact edition, or any other edition of SQL Server.<ref name="NoSSCEonRT">{{cite web|title=How do i run SQL Server Compact 3.5 on Windows 8 developer preview?|url=http://social.msdn.microsoft.com/Forums/en-US/winappswithcsharp/thread/f71c518c-c288-459e-917f-52b9cf8442d7|publisher=social.msdn.microsoft.com|access-date=11 March 2013}}</ref>

{|class="wikitable"
|+Versions
!Official name
!Common name
!Release date
!Support date
|-
|{{ubl|SQL Server 2000 Windows CE Edition|SQL Server CE 1.0}}
|SQL CE 1.0
|2000-10-26<ref>{{cite web |date=2000-10-26 |title=Microsoft Launches SQL Server 2000 Windows CE Edition at PASS 2000 |work=news.microsoft.com |url=https://news.microsoft.com/2000/10/26/microsoft-launches-sql-server-2000-windows-ce-edition-at-pass-2000/ |access-date=2022-04-16}}</ref>{{^ |2000-06-30 Beta=https://news.microsoft.com/2000/04/19/microsoft-details-sql-server-2000-windows-ce-edition-features-and-announces-beta-release-date/}}
|
|-
|{{ubl|SQL Server 2000 Windows CE Edition 1.1|SQL Server CE 1.1}}
|SQL CE 1.1
|2001-03-21<ref>{{cite web |date=2001-03-21 |title=Microsoft Delivers Support for Embedded Devices With Release of SQL Server 2000 Windows CE Edition Version 1.1 |work=news.microsoft.com |url=https://news.microsoft.com/2001/03/21/microsoft-delivers-support-for-embedded-devices-with-release-of-sql-server-2000-windows-ce-edition-version-1-1/ |access-date=2022-04-16}}</ref>{{^ |2002-01-22 SP1=https://news.microsoft.com/2002/01/22/microsoft-releases-service-pack-1-for-sql-server-2000-windows-ce-edition/ |2001-04-18 Evaluation=https://news.microsoft.com/2001/04/18/developers-can-go-mobile-with-microsoft-sql-server-2000-windows-ce-evaluation-edition/}}
|
|-
|{{ubl|SQL Server 2000 Windows CE Edition 2.0|SQL Server CE 2.0}}
|SQL CE 2.0
|2002-09-16<ref>{{cite web |date=2002-09-16 |title=Microsoft Delivers Next Stage of .NET Solution For Enterprise Mobile Development |work=news.microsoft.com |url=https://news.microsoft.com/2002/09/16/microsoft-delivers-next-stage-of-net-solution-for-enterprise-mobile-development/ |access-date=2022-04-16}}</ref>{{^ |2002-04-10 Beta=https://news.microsoft.com/2002/04/10/teched-2002-microsoft-extends-xml-web-services-support-into-every-facet-of-the-net-enterprise-server-family/}}
|
|-{{^ |codename=Laguna}}
|SQL Server 2005 Mobile Edition
|SQL CE 3.0
|2006-01-14{{^ |2004-07-26 Beta2=https://news.microsoft.com/2004/07/26/microsoft-announces-sql-server-2005-support-for-amd64/ |2004-12-03 CTP=https://news.microsoft.com/2004/12/03/microsoft-releases-updates-for-sql-server-2005-while-enterprise-customers-continue-to-choose-sql-server-2000-over-the-competition/ |2006-11-15 RC=https://news.microsoft.com/2006/11/15/microsoft-advances-data-platform-for-customer-gain/}}
|
|-
|SQL Server 2005 Compact Edition
|SQL CE 3.1
|2007-02-19
|2016-04-12<ref name="LCSQLCE31">{{cite web |url=https://docs.microsoft.com/en-us/lifecycle/products/microsoft-sql-server-2005 |title=Microsoft SQL Server 2005 |department=Lifecycle |website=[Microsoft Docs](/source/Microsoft_Docs) |access-date=2021-02-26}}</ref>
|-
|SQL Server Compact 3.5
|SQL CE 3.5
|2008-02-19{{^ |2008-08-06 RTM?=https://news.microsoft.com/2008/08/06/microsoft-releases-sql-server-2008/}}
|2018-04-10<ref name="LCSQLCE35">{{cite web |url=https://docs.microsoft.com/en-us/lifecycle/products/microsoft-sql-server-compact-35 |title=Microsoft SQL Server Compact 3.5 |department=Lifecycle |website=[Microsoft Docs](/source/Microsoft_Docs) |access-date=2021-02-26}}</ref>
|-
|SQL Server Compact 4.0
|SQL CE 4.0
|2011-04-13
|2021-07-13<ref name="LCSQLCE40">{{cite web |url=https://docs.microsoft.com/en-us/lifecycle/products/microsoft-sql-server-compact-40 |title=Microsoft SQL Server Compact 4.0 |department=Lifecycle |website=[Microsoft Docs](/source/Microsoft_Docs) |access-date=2021-02-26}}</ref>
|}

== Support ==
SQL CE databases can support [ACID](/source/ACID)-compliance, but do not meet the durability requirement by default because AutoFlush buffers changes in memory (including enlisted ambient transactions and explicit SQL CE transactions that do not override the Commit() call with an CommitMode.Immediate value). Therefore, committed transaction changes can be lost. To meet the durability requirement the commit call on the transaction must specify the immediate flag.<ref name="MSDNAutoFlush">{{cite web|title=Maintaining Databases (SQL Server Compact Edition)| date=28 June 2007 |url=http://msdn.microsoft.com/en-us/library/ms172411(v=sql.90).aspx}}</ref> Like [Microsoft SQL Server](/source/Microsoft_SQL_Server), SQL CE supports transactions, referential integrity constraints, locking as well as multiple connections to the database store.<ref name="Lap1"/> However, [nested transaction](/source/nested_transaction)s are not supported, even though parallel transactions (on different tables) are.<ref>{{cite web | url = https://technet.microsoft.com/en-us/library/ms172400.aspx | title = Transactions (SQL Server Compact Edition)  | access-date = 2007-07-03}}</ref> The current release does not support [stored procedures](/source/stored_procedures)<ref name="Lap1"/> or native [XML](/source/XML) data type either.<ref name="JAD"/> It uses a subset of [T-SQL](/source/T-SQL)<ref name="Datasheet"/> for querying and due to lack of XML support, [XQuery](/source/XQuery) is not supported either.<ref name="JAD"/> Queries are processed by an optimizing query processor.<ref name="Feat">{{cite web | url = https://technet.microsoft.com/en-us/library/ms172037.aspx | title = Overview of Databases (SQL Server Compact Edition)  | access-date = 2007-07-03}}</ref> SQL CE databases also support indexing, as well as support remote data replication (local caching of data in remote databases) and merge replication (bidirectional synchronization with master databases).<ref>{{cite web | url = https://technet.microsoft.com/en-us/library/ms171986.aspx | title = Overview of Databases (SQL Server Compact Edition)  | access-date = 2007-07-03}}</ref>

SQL CE databases can be created and managed from [Microsoft Visual Studio](/source/Microsoft_Visual_Studio) and some older versions of [SQL Server Management Studio](/source/SQL_Server_Management_Studio) as well.<ref name="Feat"/>

== File format ==
{{Infobox file format
| name = SQL Server Compact
| extension = <code>.sdf</code>
| mime = 
| owner = [Microsoft](/source/Microsoft)
| creatorcode =
| genre = [Relational database](/source/Relational_database)
| containerfor = 
| containedby = 
| extendedfrom = 
| extendedto = 
}}
SQL CE databases reside in a single '''''.sdf''''' file,<ref name="Arch">{{cite web | url = http://msdn2.microsoft.com/en-us/library/bb380177.aspx | title = Data Storage Architecture with SQL Server 2005 Compact Edition | access-date = 2007-07-03}}</ref> which can be up to 4 [GB](/source/Gigabyte) in size.<ref name="Lap1"/> The ''.sdf'' file can be encrypted with 128-bit [encryption](/source/encryption) for data security.<ref name="Arch"/> SQL CE runtime mediates concurrent multi-user access to the ''.sdf'' file. The ''.sdf'' file can simply be copied to the destination system for deployment, or be deployed through [ClickOnce](/source/ClickOnce). SQL CE runtime has support for DataDirectories.<ref name="New"/> Applications using an SQL CE database need not specify the entire path to an ''.sdf'' file in the [ADO.NET](/source/ADO.NET) connection string, rather it can be specified as ''|DataDirectory|\<database_name>.sdf'', defining the data directory (where the ''.sdf'' database file resides) being defined in the [assembly manifest](/source/Manifest_(CLI)) for the application.{{citation needed|date=November 2016}}

SQL Server Management Studio 2005 can read and modify CE 3.0 and 3.1 database files (with the latest service pack), but SQL Server Management Studio 2008 (or later) is required to read version 3.5 files.  Microsoft Visual Studio Express 2008 SP1 can create, modify, and query CE 3.5 SP1 database files. SQL Server Management Studio cannot read CE 4.0 files.  Visual Studio 2010 SP1 can handle CE 4.0 database files.{{citation needed|date=November 2016}}

The .sdf ("Sqlce Database File") naming convention is optional, and any extension can be used.{{citation needed|date=November 2016}}

Setting a password for the database file is optional. The database can be compressed and repaired with the option of the compacted/repaired database to be placed into a new database file.{{citation needed|date=November 2016}}

==Deprecation==
In February 2013, Microsoft announced that SQL Server Compact Edition had been deprecated.<ref>{{cite web|title=Port SQL Compact to Windows RT|url=https://connect.microsoft.com/SQLServer/feedback/details/776328/port-sql-compact-to-windows-rt|author=Barranis, Patrick|date=2013-01-11|website=Microsoft Connect|access-date=2016-06-25}}</ref>

Although no new versions or updates are planned, Microsoft will continue to support SQL Compact through their standard lifecycle support policy. Extended support for SQL Server Compact 4.0 ended on July 13, 2021.<ref>{{cite web|title=Microsoft SQL Server Compact 4.0 Support Dates|url=https://docs.microsoft.com/en-us/lifecycle/products/microsoft-sql-server-compact-40|access-date=2020-09-17}}</ref>

==See also==
*[Mobile database](/source/Mobile_database)
*[SQLite](/source/SQLite)
*{{slink|SQL Server Express#LocalDB}}
*[Access Database Engine](/source/Access_Database_Engine) (ACE and formerly JET)
*[HSQLDB](/source/HSQLDB)
*[Firebird](/source/Firebird_(database_server))

==References==
{{reflist}}

== External links ==
* [https://learn.microsoft.com/en-us/archive/blogs/sqlservercompact/ Microsoft's Embedded Database - SQL Server Compact - Team Blog] at [Microsoft Learn](/source/Microsoft_Learn)
* {{webarchive |url=https://web.archive.org/web/20160215155139/http://blogs.msdn.com/b/sqlservercompact |title=Microsoft's Embedded Database - SQL Server Compact - Team Blog}}

{{Windows Mobile}}
{{Microsoft development tools}}

Category:Microsoft server technology
Category:Windows Mobile
Category:Relational database management systems
Category:Microsoft database software
Category:Discontinued Microsoft software

[fr:Microsoft SQL Server#Compact Edition](/source/fr%3AMicrosoft_SQL_Server)
[ja:Microsoft SQL Server#MSDE](/source/ja%3AMicrosoft_SQL_Server)

---
Adapted from the Wikipedia article [SQL Server Compact](https://en.wikipedia.org/wiki/SQL_Server_Compact) by Wikipedia contributors ([contributor history](https://en.wikipedia.org/wiki/SQL_Server_Compact?action=history)). Available under [Creative Commons Attribution-ShareAlike 4.0 International](https://creativecommons.org/licenses/by-sa/4.0/). Changes may have been made.
