January 17, 2014 at 12:54 pm
Can I use two ddl after with cte statement?
The first ddl is to use a merget statement to update a column.
the second ddl is to insert the updated record into another log table.
Thanks,
January 17, 2014 at 1:03 pm
Being pedantic, you can't use any ddl statements with a cte.
Without being pedantic and trying to be useful, I assume you want to say DML. However, ctes work only for one statement. You could insert the result of your cte into a temp table and use it for both statements.
January 17, 2014 at 1:05 pm
Thanks, you are right I mean DML, one update, one insert,
it looks like using a temp table is a good solution.
January 17, 2014 at 1:10 pm
sqlfriends (1/17/2014)
Thanks, you are right I mean DML, one update, one insert,it looks like using a temp table is a good solution.
Actually depends what you are attempting to accomplish. Why don't you provide the code you are using and we can see if it needs to be done using a temporary table or not.
January 17, 2014 at 1:10 pm
Have you tried the OUTPUT clause?
January 19, 2014 at 4:00 am
Remember, while it has the word "table" in the definition of Common Table Expression, a CTE is nothing but a query. It's not a table. Comparing it to a temp table means you might be under that impression.
"The credit belongs to the man who is actually in the arena, whose face is marred by dust and sweat and blood"
- Theodore Roosevelt
Author of:
SQL Server Execution Plans
SQL Server Query Performance Tuning
Viewing 6 posts - 1 through 5 (of 5 total)
You must be logged in to reply to this topic. Login to reply