From a previous post I got an example of creating a Horizontal Partition. I have altered the code in an attempt to understand why the partition I want fails on insert. The altered script is:
create table Table_A_Jan (Col1 int not null, Col2 char(2) not null CHECK (col2 = 'RL')--CHECK (Col2 >= cast('20060101' as datetime) and Col2 < cast('20060201' as datetime))--,--Col3 char(5) not null, CONSTRAINT [PKJan] PRIMARY KEY CLUSTERED ([Col1], [Col2]/*, [Col3] */) WITH FILLFACTOR = 95 ON [PRIMARY] )
create table Table_A_Feb (Col1 int not null,Col2 datetime not null CHECK (col2 = 'RP') --(Col2 >= cast('20060201' as datetime) and Col2 < cast('20060301' as datetime))--,--Col3 char(5) not null, CONSTRAINT [PKFeb] PRIMARY KEY CLUSTERED ([Col1], [Col2]/*, [Col3]*/) WITH FILLFACTOR = 95 ON [PRIMARY] )
CREATE VIEW A AS SELECT * FROM Table_A_Jan
UNION ALL
SELECT * FROM Table_A_Feb
Then the insert
INSERT INTO A (Col1, Col2/*, Col3*/) VALUES (45, 'RL'--'2006-01-21 23:55:34.000'--, '00073' )
And the resulting error message
because the primary key of table '[AAAA].[dbo].[Table_A_Jan]' is not included in the union result.
As long as I keep Col2 as date time everything works. Why does it fail when I want the CHECK contraint to be equal to a particular string?
(Sorry about the font issue don't get what is going on here)
Andrew.
This forum where you will seek help for Analysis Services related questions. I know your quest started from exploring solutions for Analysis Services application, but looks like you missing some basic knowlege on relational databases (SQL Server and likes). I suggest you get yourself a good book or tutorial on how to work with SQL.
HTH
Edward.
--
This posting is provided "AS IS" with no warranties, and confers no rights.
No comments:
Post a Comment