52

I used to open sdf (sqlCE) files with visual-studio? or sql-server? I really don't remember. Now I can't open this sdf file. With what program do I need to open it?

6 Answers 6

88

Try LINQPad, it works for SQL Server, MySQL, SQLite and also SDF (SQL CE 4.0). Best of all it's free!

LINQPad

Steps with version 4.35.1:

  1. click 'Add Connection'

  2. Click Next with 'Build data context automatically' and 'Default(LINQ to SQL)' selected.

  3. Under 'Provider' choose 'SQL CE 4.0'.

  4. Under 'Database' with 'Attach database file' selected, choose 'Browse' to select your .sdf file.

  5. Click 'OK'.

  6. Voila! It should show the tables in .sdf and be able to query it via right clicking the table or writing LINQ code in your favorite .NET language or even SQL. How cool is that?

3
  • Not open some .sdf files for me. Exception appear on open.
    – Enyby
    May 10, 2013 at 18:50
  • Enyby, did you pick the 'SQL CE 4.0' radio button?
    – Chris Voon
    Aug 3, 2013 at 4:11
  • It only works if you have the SQL CE database drivers. If that option is not in the list, Then you might consider the next best choice (next answer, below).
    – tgolisch
    Feb 23, 2015 at 15:59
36

It's a SQL Compact database. You need to define what you mean by "Open". You can open it via code with the SqlCeConnection so you can write your own tool/app to access it.

Visual Studio can also open the files directly if was created with the right version of SQL Compact.

There are also some third-party tools for manipulating them.

5
  • 3
    thank's for the help, when i write Open i mean - to see tables and to write query's (i thing that i use to open with the visual-studio) but now i cant
    – Gold
    Mar 3, 2010 at 21:43
  • 4
    More third party tools here: erikej.blogspot.com/2009/04/sql-compact-3rd-party-tools.html
    – ErikEJ
    Jan 23, 2012 at 18:53
  • 4
    Or just use SQL Server Management Studio. (1) Open SQL Server Management Studio, or if it's running select File -> Connect Object Explorer... (2) In the Connect to Server dialog change Server type to SQL Server Compact Edition (3) From the Database file dropdown select <Browse for more...> (4) Open your SDF file. Oct 31, 2012 at 21:47
  • 2
    If you open in Visual Studio, it has to be VS 2012 or lower. Support was removed in VS 2013.
    – Jason
    Aug 22, 2014 at 0:12
  • There is also SQLite & SQL Server Compact Toolbox extension for Visual Studio
    – Tung
    Oct 31, 2020 at 17:46
14

You can use SQL Compact Query Analyzer

https://github.com/christianhelle/sqlcequery

SQL Compact Query Analyzer is really snappy. 3 MB download, requires an install but really snappy and works.

0
2

In addition to the methods described by @ctacke, you can also open SQL Server Compact Edition databases with SQL Server Management Studio. You'll need SQL Server 2008 to open SQL CE 3.5 databases.

0

If you simply need to view the table and run queries on it you can use this third party sdf viewer. It is a lightweight viewer that has all the basic functionalities and is ready to use after install.

and ofcourse, its Free.

0

It can be opened using Visual Studio 2012.Follow the below path in VS after opening the project. View->Server Explorer->

enter image description here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.