1

I'm trying to create a composite primary key like this:

CREATE TABLE TableA (Column1 nvarchar(50) NOT NULL, Column2 nvarchar(3) NOT NULL, Column3 nvarchar(50) NOT NULL)

ALTER TABLE TableA ADD CONSTRAINT PK_AuxGroupData PRIMARY KEY CLUSTERED (Column1 , Column2)

By some reason, the second query is generating the following exception:

System.Data.SqlServerCe.SqlCeException occurred Message=The constraint specified is not valid. Source=SQL Server Compact ADO.NET Data Provider HResult=-2147217900 NativeError=25505

This happens when I run my project from Microsoft Visual Studio 2010 in Debug Mode.

My development machine has:

  • Microsoft SQL Server 2008 Compact 3.5 SP2 ENU
  • Microsoft SQL Server 2008 Compact 3.5 SP2 x64 ENU

Any help please?

RedEagle
  • 4,418
  • 9
  • 41
  • 64

1 Answers1

1

Unfortunately, SQL Server Compact Edition does not support clustered indexes. This goes for the Primary Key as well.

Link showing that it does not support clustered indexes:
- http://technet.microsoft.com/en-us/library/ms345331(v=sql.105).aspx

Link showing that PRIMARY KEYs are maintained by unique indexes:
- http://technet.microsoft.com/en-us/library/ms173393.aspx

MatBailie
  • 83,401
  • 18
  • 103
  • 137