sql server - T-SQL : UNION ALL view not updatable because a partitioning column was not found -


how can insert in view date constraints?

here tables resulted after clicking on script create table :

table 1:

create table [dbo].[tbl_zaua_1_17](     [id] [int] not null,     [date] [datetime] null,       constraint [pk_tbl_zaua_1_17] primary key clustered  (     [id] asc )with (pad_index = off, statistics_norecompute = off, ignore_dup_key = off, allow_row_locks = on, allow_page_locks = on) on [primary] ) on [primary] go  set ansi_padding off go  alter table [dbo].[tbl_zaua_1_17]   check add  constraint [ck_tbl_zaua_1_17]   check  (([date]<'2014-01-18 00:00:00.000' , [date]>'2014-01-16 00:00:00.000')) go  alter table [dbo].[tbl_zaua_1_17] check constraint [ck_tbl_zaua_1_17] go` 

table 2:

create table [dbo].[tbl_zaua_1_11](     [id] [int] not null,     [date] [datetime] null,  constraint [pk_tbl_zaua_1_11] primary key clustered  (     [id] asc )with (pad_index = off, statistics_norecompute = off, ignore_dup_key = off, allow_row_locks = on, allow_page_locks = on) on [primary] ) on [primary]  go  alter table [dbo].[tbl_zaua_1_11]  check add  constraint [ck_tbl_zaua_1_11] check  (([date]<'2014-01-12 00:00:00.000' , [date]>'2014-01-10 00:00:00.000')) go  alter table [dbo].[tbl_zaua_1_11] check constraint [ck_tbl_zaua_1_11] go` 

view creation:

create view zaua1    select * [dbo].[tbl_zaua_1_11]    union    select * [dbo].[tbl_zaua_1_17]` 

insert gives error:

union view not updatable because partitioning column not found.

insert [dbo].[zaua1] values (3,'2014-01-11') 

this example can give solution problem

create table parta     (     partid int,     type varchar(10) constraint ckparta_type check (type = 'parta'),     value int,     constraint pkparta primary key(partid, type),     )     create table partb     (     partid int,     type varchar(10) constraint ckpartb_type check (type = 'partb'),     value int,     constraint pkpartb primary key(partid, type)     )     go     create view part         select partid, type, value     parta     union     select partid, type, value     partb     go       insert part     select 1,'partb',1     union     select 2,'parta',2     go     update part     set value = 20     go      select *     part      go     delete part     go 

Comments

Popular posts from this blog

java - Intellij Synchronizing output directories .. -

git - Initial Commit: "fatal: could not create leading directories of ..." -