• Doing all of this by hand is going to be a ton of work. Management is willing to have you guys spend weeks worth of man-hours to build something that third party tools have already built. That's pretty counter-intuitive.

    However, I can at least point you in some directions that should help. First and foremost, instead of trying to figure out what changes have occurred, get your database into a source control system. Best bet is to use the one in use by your developers, but there are free ones out there. Us the source control as the building point for all the database builds going forward. You can use branches and labels to always know what's going on with your system.

    Next, instead of building software to automate these steps, look to open-source solutions. TeamCity is a continuous integration manager that you can get for free. It will work with your source control system to understand what changes have occurred over time or in an automated fashion.

    With all that in hand, you have most of what you need. The last step is the hardest. You're going to have to pull together the scripts and put them in the correct order. There's no easy way around this without purchasing third party help, so you'll have to do a bunch of coding to make it happen. I'd suggest using an external language such as PowerShell or C# to put this bit together. You'll need to have a mechanism that walks the dependencies within SQL Server, following primary keys and foreign keys programmatically, to put your scripts into the correct order AND make them into ALTER or CREATE as needed. This is going to be the hardest part of this process. It's also where you would be so much better off looking at third party tooling.

    One alternative that might be free for you, use SQL Server Database Tools which is built into Visual Studio. Otherwise, you need to look at alternatives like Redgate Software.

    "The credit belongs to the man who is actually in the arena, whose face is marred by dust and sweat and blood"
    - Theodore Roosevelt

    Author of:
    SQL Server Execution Plans
    SQL Server Query Performance Tuning