I'm writing a software application in C#.Net that connects to a SQL Server database. My C# project is under SVN version control, but I'd like to include my database schema in the SVN repository as well. An answer to a previous question of mine suggested storing the scripts to generate the database in version control. Is there a way to automatically generate these scripts from an existing database?
I'm very new to SQL Server, but I noticed in management studio that the SQL commands to create a table can be generated automatically by right clicking on the table and clicking "Script Table As". Is there an equivalent command that would work with the entire database?
You didn't mention which version of SQL Server, but in 2008 (and possibly earlier), you can right-click the database and choose Tasks -> Generate Scripts. The wizard will walk you through the steps.
You can use SQL-DMO or SQL SMO to script out, or a product like APEXSQLScript (if you have a lot of dependencies, you're going to want to use a mature 3rd party tool like this).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With