Microsoft SQL Server Administration

SQL Compact Edition & LocalDB

David Hoksza http://siret.cz/hoksza SQL Server Compact Edition (CE)

https://technet.microsoft.com/en- us/library/hh278312(v=sql.10).aspx SQLCE overview • Embedded version of the “big” SQL Server o Runs in process of application, i.e. does not run as a service o No need of installation – distributed as set of DLLs with the application o The application simply points to the DB file in its connection string o Aimed at small application developers • Limited version of the “big” SQL Server o Does not support stored procedures, views, … o DB can be password protected, but no access restriction on the level of tables o Limited to 4GB and 256 connections (within a single computer) o Limited T-SQL, such as HAVING for one column only, DISTINT in aggregates o Not supported by SSMS → Visual Studio • Distributed free of charge SQLCE components (1)

Optional components

Access model- dependent components

Required components

source: http://blogs.msdn.com/b/laxmi/archive/2009/10/07/sql-ce-binaries-details.aspx SQLCE components (2) Accessing SQLCE using Visual Studio • SQLCE not supported by default in Visual Studio 2013 → SQL Server Compact Toolbox

• Connection string needs to contain attribute Data source and can contain password Data source=“C:\temp\TestDb.mdf;Password=pwd”

• SQL Server Compact 4.0 Class Library o The System.Data.SqlServerCe namespace is the managed data provider for SQL Server Compact 4.0 → need to include the reference SQLCE versions • SQLCE 3.5 (download)

• SQLCE 4.0 (download) o Came with SQL Server 2012 and removed support for

• Data replication (data replication with SQL Server using Sync Framework, merge replication or remote data access (RDA))

• SQL Server Integration Services

• LINQ to SQL

• Does not support , and Windows CE devices SQL Server Express LocalDB https://msdn.microsoft.com/en-us/library/hh510202.aspx Overview

• Targeted to application developers

• Allows to create and start working with a DB without complex configuration tasks

• SQL Express LocalDB runtime is about 33 MB (160 MB on disk) , i.e. it is much smaller than the full blown SQL Server Connecting to LocalDB

Data Source=(localdb)\v11.0;Integrated Security=true;AttachDbFileName=C:\MyData\Databa se1.mdf

• If an instance of LocalDB for the current user is not running, a new one is started • LocalDB runs in its own process but shares security context with the application Comparison • Main differences o Execution mode • SQL Server Compact is an in-proc DLL • LocalDB runs as a separate process

o Disk usage • SQL Server Compact is about 4 MB • LocalDB installation takes about 160 MB

o Features • SQL Server Compact offers core RDBMS functionality (querying) • LocalDB includes stored procedures, views, geometry and geography data types, ...

• Full comparison Sources • https://technet.microsoft.com/en- us/library/hh278312(v=sql.10).aspx

• https://msdn.microsoft.com/en- us/library/hh510202.aspx

• http://erikej.blogspot.com/