By submitting your email address, you agree to receive emails regarding relevant topic offers from TechTarget and its partners. You can withdraw your consent at any time. Contact TechTarget at 275 Grove Street, Newton, MA.
Once you have data in the temporary table, you can use series of INSERT, UPDATE and DELETE statements to populate other tables in the database. In some scenarios I often add an ID column to the temporary table, and then use the UPDATE…FROM statement to join permanent tables on one or more columns in the temporary table and populate the ID column. After that, I know that any rows in the temporary table where the ID equals NULL are new rows and need to be inserted. The rows where the ID column has a value are considered a match. For those rows I use another UPDATE...FROM statement where I join on the ID column and copy the values from the temporary table to the existing rows. This technique is very useful for data imports using set-based operations rather than row-by-row processing.
Dig Deeper on SQL Server Stored Procedures
Related Q&A from Roman Rehak
There are a few things you can do to tune SQL Server for improved reporting performance. Here are some generic and Reporting Services-specific ...continue reading
Learn SQL Server commands to manipulate column names in a table and turn column names into variables or rename SQL columns.continue reading
Learn why using a SQL Server stored procedures vs. a trigger can be a preferred method to retrieve data notification from a database field.continue reading
Have a question for an expert?
Please add a title for your question
Get answers from a TechTarget expert on whatever's puzzling you.