|
Question : UNION all view % is not updatable because a partitioning column was not found
|
|
I have 2 tables - SorMaster and ShippingPlanAddOnsTest. The second one I created by copying the first one into a new table. I have deleted all of the records from the ShippingPlanAddOnsTest table.
SalesOrder is the primary key - for both tables.
The first table has a constraint as follows: SalesOrder < 909999
The second table has a constraint as follows: SalesOrder > 910000
I have created a view of these tables as follows -
CREATE VIEW QMM_ShippingPlanViewTest AS SELECT * FROM dbo.SorMaster Union ALL SELECT * from QMM_ShippingPlanAddOnsTest
Why do I get the "UNION all view QMM_ShippingPlanViewTest is not updatable because a partitioning column was not found" error. I have a primary key in each table, they are the same field, and they both have a constraint on them.
I am looking to be able to add records AND update data in existing records via the view.
NOTE: I have reviewed MS article 270013, which addresses untrusted constraints. After running the script, it appears that my constraints on these 2 tables are trusted.
|
|
Answer : UNION all view % is not updatable because a partitioning column was not found
|
|
It cannot be done. See here from BOL:
If a view does not have INSTEAD OF triggers, or if it is not a partitioned view, then it is updatable only if the following conditions are satisfied:
The select_statement has no aggregate functions in the select list and does not contain the TOP, GROUP BY, UNION (unless the view is a partitioned view as described later in this topic), or DISTINCT clauses. Aggregate functions can be used in a subquery in the FROM clause as long as the values returned by the functions are not modified. For more information, see Aggregate Functions.
select_statement has no derived columns in the select list. Derived columns are result set columns formed by anything other than a simple column expression, such as using functions or addition or subtraction operators.
The FROM clause in the select_statement references at least one table. select_statement must have more than non-tabular expressions, which are expressions not derived from a table. For example, this view is not updatable: CREATE VIEW NoTable AS SELECT GETDATE() AS CurrentDate, @@LANGUAGE AS CurrentLanguage, CURRENT_USER AS CurrentUser
|
|
|
|