Why can the target of the OUTPUT INTO clause not be a view?
-
16-10-2019 - |
Pergunta
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?
Solução
From MSDN - Output clause:
"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. "
Licenciado em: CC-BY-SA com atribuição
Não afiliado a dba.stackexchange