In MS SQL Server 2008 R2, how do I create a new database based on the schema of the old one, but without copying any of the data along with it? I am using SQL Server management studio.
CREATE TABLE new_table AS (SELECT * FROM old_table WHERE 1=2); For example: CREATE TABLE suppliers AS (SELECT * FROM companies WHERE 1=2); This would create a new table called suppliers that included all columns from the companies table, but no data from the companies table.
Right click the Database and select Tasks
-> Generate Scripts
.
You can you then select all the objects you require or only certain objects.
There are some Script Options that you should look at:
You can either create these to a new Query Window or save them to SQL Files.
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