patternsqlMinor
Why can the target of the OUTPUT INTO clause not be a view?
Viewed 0 times
whythecantargetintooutputviewnotclause
Problem
Here is my statement:
DELETE FROM table1
OUTPUT deleted.col1, deleted.col2
INTO view1;
It gives me this error:
The target 'view1' of the OUTPUT INTO clause cannot be a view or common table expression.
The view is simple and updatable. Why can I not insert into an updatable view using the OUTPUT clause?
DELETE FROM table1
OUTPUT deleted.col1, deleted.col2
INTO view1;
It gives me this error:
The target 'view1' of the OUTPUT INTO clause cannot be a view or common table expression.
The view is simple and updatable. Why can I not insert into an updatable view using the OUTPUT clause?
Solution
From MSDN - Output clause:
"The OUTPUT clause is not supported in the following statements:
"
"The OUTPUT clause is not supported in the following statements:
- DML statements that reference local partitioned views, distributed partitioned views, or remote tables.
- INSERT statements that contain an EXECUTE statement.
- Full-text predicates are not allowed in the OUTPUT clause when the database compatibility level is set to 100.
- The OUTPUT INTO clause cannot be used to insert into a view, or rowset function.
- A user-defined function cannot be created if it contains an OUTPUT INTO clause that has a table as its target.
"
Context
StackExchange Database Administrators Q#2767, answer score: 5
Revisions (0)
No revisions yet.