sql server - copying related data using CTE within one SP? -
I have to copy the data for a student (clone student) which includes three tables:
<
- To complete this, call me
- Performing student records by competing with existing student records and getting new students Classes
- Create Record student subject to all current students about using new student student and create
- Students topic comments recorded using freshman student. Blockquote>
... hope you got it
So, is it a great way to use CTE in a store process? (I am using SQL Server 2005)
INSERT and UPDATE statements operate on only one table There are times. You need 3 tables that require INSERTs. You can of course insert several rows in the table in one line, and I think it is good to do it when possible, but you can not put rows in several tables together.
Think in this way. When you are pulling records in a single result set from several sources, you do the query. When you modify the data, you are pulling records from several sources to apply changes to the same result set.
Besides, I hate to say this but there are some things that are super-elegant solutions. To ensure that all 3 INSERT statements are in the form of an atomic transaction (all or nothing), your stored procedure needs to implement some best practices, the final result can be vocabulary and fun, but It will be quick, effective, safe, sound and up-to-date.
Comments
Post a Comment