Sql Server 2000I am trying to split out a large table and use a partioned view...I have reduced the issue to the following example codeIF EXISTS(SELECT name FROM sysobjects WHERE name = N'TT1' AND type = 'U') DROP TABLE TT1GOCREATE TABLE TT1 ( uid INTEGER not null ,uidstatus INT not null CHECK (uidstatus = 1) ,CONSTRAINT XX1 PRIMARY KEY(uid, uidstatus)-- ,CONSTRAINT XX1 PRIMARY KEY(uid))GOIF EXISTS(SELECT name FROM sysobjects WHERE name = N'TT2' AND type = 'U') DROP TABLE TT2GOCREATE TABLE TT2 ( uid INTEGER not null ,uidstatus INT not null CHECK (uidstatus =2) ,CONSTRAINT XX2 PRIMARY KEY(uid, uidstatus)-- ,CONSTRAINT XX2 PRIMARY KEY(uid))GOIF EXISTS (SELECT TABLE_NAME FROM INFORMATION_SCHEMA.VIEWS WHERE TABLE_NAME = N'vTT') DROP VIEW vTTGOCREATE VIEW vTTAS SELECT uid ,uidstatusFROM TT1UNION ALLSELECT uid ,uidstatusFROM TT2GOSET STATISTICS IO ONSET STATISTICS PROFILE ONselect * from vtt where uidstatus = 1 and uid = 1 --uses just table TT1 :-)select * from vtt where uidstatus = 2 and uid = 1 --uses just table TT2 :-) select * from vtt where uidstatus = 1 --uses both TT1 and TT2 :-(
The first select statement only uses table TT1The second select statement used both TT1 and TT2, but I really just want it to use TT1 as TT1 will have the active status (e.g. when SELECT'ing a list of items where the status is constrained to 1, only use TT1, TT2 will not be touched)I hope this makes sense and that what I want is possible