Questions tagged [sql-server-ce]

3695 questions
18
votes
2 answers

Creating stored procedure with declare and set variables

I am creating one stored procedure where only value has to pass and I have to retrieve multiple values from multiple tables. I tried to do like this but its showing errors like Incorrect Syntax near Begin and Must declare the scalar variable…
LovingMVC
  • 305
  • 3
  • 5
  • 15
18
votes
1 answer

Create SQLCE database programmatically

[EDITED - with answer] Following is my code to create SQL CE database programmatically: /* get the Path */ var directoryName = System.IO.Path.GetDirectoryName(Assembly.GetEntryAssembly().Location); var fileName =…
KMC
  • 19,548
  • 58
  • 164
  • 253
18
votes
3 answers

Determine if table exists in SQL Server CE?

I know this is similar to this question, but I'm using SQL Server CE 3.5 with a WinForms project in C#. How can I determine whether a table exists? I know the IF keyword is not supported, though EXISTS is. Does information_schema exist in CE…
Michael Itzoe
  • 1,949
  • 4
  • 29
  • 49
18
votes
1 answer

How to get all tables names in SQL CE database?

I have a database in SQL CE (sdf file) and I need to get all names of the tables. How to do it?
Gold
  • 60,526
  • 100
  • 215
  • 315
18
votes
9 answers

SQL Compact Edition 3.5 - Access to the database file is not allowed

I developed an application (100% local, no access to servers) using SQL Server Compact 3.5, and it works fine on my computer. However, when I deployed it on another computer, it shows this error: Access to the database file is not allowed. [ File…
WoF_Angel
  • 2,569
  • 9
  • 35
  • 54
17
votes
1 answer

Microsoft replacement of SQL Server CE

Why is SQL Server CE deprecated and what is (or will be) Microsoft replacement for portable database? LocalDB requires local .msi installation, and SQlite requires 3rd-party bindings to ADO.NET. Working in Visual Studio, I would prefer Microsoft…
KMC
  • 19,548
  • 58
  • 164
  • 253
17
votes
4 answers

Profiler for Sql CE

i wonder if there is something similar to Sql Profiler for Sql Server Compact Edition? i use SqlCE as backend for a desktop application and it would be really great to have something like sql profiler for this embedded database. or at least…
Joachim Kerschbaumer
  • 9,695
  • 7
  • 49
  • 84
17
votes
8 answers

How do I select the first row per group in an SQL Query?

I've got this SQL query: SELECT Foo, Bar, SUM(Values) AS Sum FROM SomeTable GROUP BY Foo, Bar ORDER BY Foo DESC, Sum DESC This results in an output similar to this: 47 1 100 47 0 10 47 2 10 46 0 100 46 1 10 46 2 10 44 0 …
mafu
  • 31,798
  • 42
  • 154
  • 247
16
votes
2 answers

Why doesn't SQL Server CE support varchar?

I was creating a table in SQL Server CE and realized it doesn't support varchar. Looking this up, I found that "non-Unicode text columns (varchar, char, text) and smallmoney are not supported; although nvarchar, nchar, ntext, and money are…
Edward Tanguay
  • 189,012
  • 314
  • 712
  • 1,047
16
votes
6 answers

Correct way to close database connection in event of exception

Does the following code leave the connection open if there is an exception? I am using a Microsoft SQL compact edition database. try { SqlCeConnection conn = new SqlCeConnection(ConnectionString); conn.Open(); using (SqlCeCommand cmd…
lowlyintern
  • 231
  • 1
  • 2
  • 5
15
votes
3 answers

Microsoft SQL Compact Edition rename column

I am having problems renaming a column in SQL Server Compact Edition. I know that you can rename a table using sp_rename, but this doesn't work with columns. I've searched for an alternative, but haven't found one. Can I delete a column and then…
lucian
  • 201
  • 1
  • 2
  • 9
15
votes
4 answers

sqlbulkcopy using sql CE

Is it possible to use SqlBulkcopy with Sql Compact Edition e.g. (*.sdf) files? I know it works with SQL Server 200 Up, but wanted to check CE compatibility. If it doesnt does anyone else know the fastest way of getting a CSV type file into SQL…
Mark H
  • 707
  • 1
  • 11
  • 21
15
votes
2 answers

How do I rename a table in SQL Server Compact Edition?

I've designed my SQL CE tables using the built-in designer in VS2008. I chose the wrong names for a couple. I am now completely stuck trying to find a way to rename them. I am refusing to believe that such a feature could have been "forgotten". How…
Roman Starkov
  • 59,298
  • 38
  • 251
  • 324
14
votes
7 answers

Unable to load the native components of SQL Server Compact

I've installed SQL Server Compact Edition 4.0 on Win7 x64 and it runs both for Asp.Net and Desktop Applications. This PC also have Visual Studio 2010 SP1 installed. But my Server 2008 R2 produces following error for Asp.Net applications, although it…
HasanG
  • 12,734
  • 29
  • 100
  • 154
14
votes
2 answers

How to delete all data in a table in SQL CE?

SQL CE does not support TRUNCATE command. To clear a table I have to use DELETE. Is there a quicker/better way to clear the data then the following command? DELETE FROM FooTable WHERE id !='ABC'
KMC
  • 19,548
  • 58
  • 164
  • 253