Hi,
Can I use CTE for insert, update and delete opeation ?
Or its only use for select command only ???
Thanks,
Sidhartha Patnaik
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Priyanka SinghPosted Apr 23, 2019, 2:37 AM
Using the CTE –
We can define CTEs by adding a WITH clause directly before SELECT, INSERT, UPDATE, DELETE, or MERGE statement. The WITH clause can include one or more CTEs seperated by commas. The following syntax can be followed:
After you define your WITH clause with the CTEs, you can then reference the CTEs as you would refer any other table. However, you can refer a CTE only within the execution scope of the statement that immediately follows the WITH clause. After you’ve run your statement, the CTE result set is not available to other statements.
Rajeev KumarPosted Mar 7, 2023, 5:30 AM
A CTE must be followed by a single SELECT, INSERT, UPDATE, MERGE, or DELETE statement that references some or all the CTE columns. A CTE can also be specified in a CREATE VIEW statement as part of the defining SELECT statement of the view.
Vinitha TPosted Nov 19, 2021, 3:06 PM
Sidhartha PatnaikPosted May 4, 2019, 8:59 AM
Sidhartha PatnaikPosted Apr 23, 2019, 2:00 AM
Rajanikant HawaldarPosted Apr 23, 2019, 12:34 AM
Amit KumarPosted Apr 23, 2019, 12:25 AM