Re: Partitioned view on two columns
From: Scott Morris (bogus_at_bogus.com)
Date: 11/24/04
- Next message: Paul: "Field mapping on Importing"
- Previous message: Hugo Kornelis: "Re: Can't concatenate string"
- In reply to: Pederb: "Partitioned view on two columns"
- Next in thread: Lubor Kollar: "Re: Partitioned view on two columns"
- Messages sorted by: [ date ] [ thread ]
Date: Wed, 24 Nov 2004 11:53:50 -0500
Partitioning can only be done on a SINGLE column. You are attempting to
partition on two columns.
"Pederb" <pederb@ofir.dk> wrote in message
news:6273A219-4193-466B-BE9A-6C3735A4F9EC@microsoft.com...
> Hello,
> I'm trying to make a view that is partitioned on 4(or more) tables using
> constraints on two coulms.
>
> Constraints:
> tbl1:
> intSite=1
> datDate between convert(datetime, '01-01-1900', 103) and convert(datetime,
> '01-01-2000', 103)
>
> tbl2:
> intSite=1
> datDate between convert(datetime, '01-01-2000 00:00:01', 103) and
> convert(datetime, '01-01-2070', 103)
>
> tbl3:
> intSite=2
> datDate between convert(datetime, '01-01-1900', 103) and convert(datetime,
> '01-01-2000', 103)
>
> tbl4:
> intSite=2
> datDate between convert(datetime, '01-01-2000 00:00:01', 103) and
> convert(datetime, '01-01-2070', 103)
>
> --Now that should be enough to differentiate the tables from each other,
so
> I create the view:
> create view view1 as select * from tbl1 union all select * from tbl2 union
> all select * from tbl3 union all select * from tbl4
>
> --And try to insert a row into the view:
> insert into view1(intId, intSite, datDate)
> values (1 ,1 , convert(datetime, '01-01-1999', 103))
>
> --But then a get the error:
> Server: Msg 4436, Level 16, State 12, Line 1
> UNION ALL view 'view1' is not updatable because a partitioning column was
> not found.
>
> So is it possible to do it?
>
> The script that does it all are below!
> --
> Chill and thanx, Peder
>
> --tbl1
> CREATE TABLE [tbl1] (
> [intId] [int] NOT NULL ,
> [intSite] [int] NOT NULL ,
> [datDate] [datetime] NOT NULL ,
> CONSTRAINT [PK_tbl1] PRIMARY KEY CLUSTERED
> (
> [intId],
> [intSite],
> [datDate]
> ) ON [PRIMARY] ,
> CONSTRAINT [CK_tbl1] CHECK ([intSite] = 1),
> CONSTRAINT [CK_tbl1_1] CHECK ([datDate] >
> convert(datetime,'01-01-1900',103) and [datDate] <=
> convert(datetime,'01-01-2000',103))
> ) ON [PRIMARY]
> GO
>
> --tbl2
> CREATE TABLE [tbl2] (
> [intId] [int] NOT NULL ,
> [intSite] [int] NOT NULL ,
> [datDate] [datetime] NOT NULL ,
> CONSTRAINT [PK_tbl2] PRIMARY KEY CLUSTERED
> (
> [intId],
> [intSite],
> [datDate]
> ) ON [PRIMARY] ,
> CONSTRAINT [CK_tbl2] CHECK ([intSite] = 1),
> CONSTRAINT [CK_tbl2_1] CHECK ([datDate] > convert(datetime,'01-01-2000
> 00:00:01',103) and [datDate] < convert(datetime,'01-01-2070',103))
> ) ON [PRIMARY]
> GO
> --tbl3
> CREATE TABLE [tbl3] (
> [intId] [int] NOT NULL ,
> [intSite] [int] NOT NULL ,
> [datDate] [datetime] NOT NULL ,
> CONSTRAINT [PK_tbl3] PRIMARY KEY CLUSTERED
> (
> [intId],
> [intSite],
> [datDate]
> ) ON [PRIMARY] ,
> CONSTRAINT [CK_tbl3] CHECK ([intSite] = 2),
> CONSTRAINT [CK_tbl3_1] CHECK ([datDate] >
> convert(datetime,'01-01-1900',103) and [datDate] <=
> convert(datetime,'01-01-2000',103))
> ) ON [PRIMARY]
> GO
> --tbl4
> CREATE TABLE [tbl4] (
> [intId] [int] NOT NULL ,
> [intSite] [int] NOT NULL ,
> [datDate] [datetime] NOT NULL ,
> CONSTRAINT [PK_tbl4] PRIMARY KEY CLUSTERED
> (
> [intId],
> [intSite],
> [datDate]
> ) ON [PRIMARY] ,
> CONSTRAINT [CK_tbl4] CHECK ([intSite] = 2),
> CONSTRAINT [CK_tbl4_1] CHECK ([datDate] > convert(datetime,'01-01-2000
> 00:00:01',103) and [datDate] < convert(datetime,'01-01-2070',103))
> ) ON [PRIMARY]
> GO
>
> create view view1 as select * from tbl1 union all select * from tbl2 union
> all select * from tbl3 union all select * from tbl4
>
> insert into view1(intId, intSite, datDate)
> values (1 ,1 , convert(datetime, '01-01-1999', 103))
>
- Next message: Paul: "Field mapping on Importing"
- Previous message: Hugo Kornelis: "Re: Can't concatenate string"
- In reply to: Pederb: "Partitioned view on two columns"
- Next in thread: Lubor Kollar: "Re: Partitioned view on two columns"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|