Sql-server – how to create backup for update tables structures in existing DB

sql serversql-server-2005sql-server-2008

I have Sql Server DB, I know I can Create thru "Generate Scripts" backup for SP and Functions then I just replace inside the script the "CREATE" with "ALTER", that will update the target DB with the latest Functions And SP but how to do that for Tables structures and "User Defined Tables" ?

Best Answer

The process of synchronizing the schema between two databases is not a simple one. In general, you will need to either write change scripts manually using ALTER TABLE commands or use specifically designed software which will generate the ALTER statements for you.

Either way, any error can cause loss of data on a massive scale if you select the wrong column to delete, or make your varchar(30) into a varchar(3) column.

I can recommend you take a look at RedGate's SQLCompare, Visual Studio Ultimate or Premium, and SQL Server Data Tools - which is free. All three will take two databases, backups or scripts and generate the DDL needed to move from one to the other.