Thursday, October 22, 2009

How to export all the SQL DDL in an SQL Server database

Once you have a project ready you need to deploy it. What you need is all the data definitions (tables / view / trigger etc.) but not the data since that was probably only for testing.
Here's how to do it in SQL Server 2008.
Launch SSMS. Right click your database and select Generate Scripts as shown:

Just follow the Script Wizard. Be sure to select script all objects in the database option:

That is it. I prefer to export it to a new query window:

And then fine tune the output ... but thats just me.