Table Migration In SSDT

Ed Elliott shows us how to use pre-deployment and post-deployment scripts to migrate table data when the tables change:

You sometimes want to do things like split a table into two or move a column into another table and when you use SSDT or the compare / merge type of deployments it can be hard to migrate the data in a single deploy as you can’t insert the data into a table that doesn’t exist and you can’t drop the data before it has bee migrated. To fix this we can use pre/post deploy scripts in SSDT. The overall process is:

  • Pre-Deploy Script, check for column to be migrated

  • Save data in new table not in SSDT (you could have it in SSDT if you use it for multiple releases etc)

  • Let SSDT drop the column and create the new one – you will need to have the option set allow data loss on incremental deployments

  • In the post-deploy copyw the data to the new table

Using separate migration tables is an interesting solution to an old problem.

Related Posts

Using The GROUPING SETS Operator

Alfonso Hernandez goes into detail with what you can do with GROUPING SETS: In T-SQL, you summarize data by using the GROUP BY clause within an aggregate query. This clause creates groupings which are defined by a set of expressions. One row per unique combination of the expressions in the GROUP BY clause is returned, and aggregate functions such […]

Read More

Database Projects: Helping Find Obsolete References

Jan Mulkens explains some of those “unresolved reference” warnings in SQL Server Data Tools database projects: if you’re developing databases in SSDT, like you should, you’re probably getting a lot of build warnings. One of the warnings you’ll see the most often is the “unresolved reference”. Usually you solve these by adding either the master, […]

Read More

Categories

January 2015
MTWTFSS
  Nov »
 1234
567891011
12131415161718
19202122232425
262728293031