How to insert the results of a cte into a table variable
Something like this?
DECLARE
@myData TABLE(
Title nvarchar(350)
On my SQL2019 edition, the above construct yield no fields inserted. Even worse, if I wanted to use UPDATE after the statement, gave a syntax error.
Instead, this construct was working also in a stored procedure:
; WITH CTE AS (
select ...
UNION ALL
select ...
)
insert into @tableVariable(fields..) (select field... from CTE)
Hope somebody will make use of this.