views:

549

answers:

3

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'

A: 

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

Adam Robinson
tryed it already, now throws an error on 'Check'
Bee gud
A: 

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

Jason Short
A: 

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