delete from checklists where checklistid not in (SELECT CHECKLISTS.CHECKLISTID FROM CHECKLISTS LEFT OUTER JOIN ItemsToChecklist ON CHECKLISTS.CHECKLISTID = ItemsToChecklist.CHECKLISTID having COUNT(ItemsToChecklist.CHECKLISTID) > 0 GROUP BY CHECKLISTS.CHECKLISTID)
Not sure why it's not liking it. Says token in error is Group. We are pulling a subset of data down from Oracle and need to clean it up a bit more when it comes down to the handheld.
Here is the script to create the two tables in question.
create table Checklists (ChecklistId int primary key not null, Groups int not null, defaultlocationid int, Title nvarchar(50));
create table ChecklistItems (ChecklistItemId int primary key not null, Description nvarchar(255) not null, Recommendation nvarchar(255) not null, HotList bit not null);
create table ItemsToChecklist(ChecklistId int not null, ChecklistItemId int not null, SortOrder int not null);
alter table ItemsToChecklist add constraint fk__checklist foreign key (ChecklistId) references Checklists (ChecklistId);
alter table ItemsToChecklist add constraint fk__checklistitem foreign key (ChecklistItemId) references ChecklistItems (ChecklistItemId);
alter table ItemsToChecklist add constraint pk__primary__ItemsToChecklist primary key (ChecklistId, ChecklistItemId);
Thanx for any help.
Sub selects (nested queries) are no supported by SQL CE. Why not do the clean up server side, to save device processing, device memory and bandwidth?
No comments:
Post a Comment