1

Does Sql Server ce Suports Check Constraints? I wanted to do something like "ALTER TABLE WITH NOCHECK ADD CONSTRAINT id_range_check CHECK ( BETWEEN and )

and this will give an error on 'WITH'

Cade Roux
  • 88,164
  • 40
  • 182
  • 265
Bee gud
  • 147
  • 2
  • 11

5 Answers5

4

SQL Server Compact does not support CHECK constraint http://technet.microsoft.com/en-us/library/ms174123(v=sql.110).aspx

ErikEJ
  • 40,951
  • 5
  • 75
  • 115
0

My experience is that CHECK CONSTAINT is not supported by SQL CE 3.5. The following code works (I originally had WITH CHECK but that failed):

ALTER TABLE [SiteUser] ADD  CONSTRAINT [FK_SiteUser_Site] FOREIGN KEY([SiteId])
REFERENCES [Site] ([SiteId])

The following execution also fails.. so now it seems I can create the foreign key but can't enforce it.. what's the point then!?

ALTER TABLE [SiteUser] CHECK CONSTRAINT [FK_SiteUser_Site]
misteraidan
  • 1,984
  • 4
  • 23
  • 31
0

"alter table [table_name] check constraint [constraint_name]" is a constraint validation statement, not a check constraint.

Antonio
  • 1
  • 2
-1

Check constraints are supported, but the "WITH NOCHECK" option is not. Try removing that.

Adam Robinson
  • 182,639
  • 35
  • 285
  • 343
-1

I believe only simple constraints are supported your example above include a BETWEEN that would not be supported.

Jason Short
  • 5,205
  • 1
  • 28
  • 45