SQL Script to Get DB Shell

  • I know there is a feature in Management Studio that can generate scripts but this requires manual action. What I want to do is copy a database from 1 server to another but just the "shell" of the database. I don't want ANY data.

    I need table structure, etc

    Anyone have dynamic script that can do this? Thanks.

  • Really, the easiest way is to right-click the database, select Taks, then click Generate SQL Scripts.

    Make sure and go to the Set Scripting Options page and use Advanced to customize the output.

    Pay special attention to: Script Logins, Script Object-Level Permissions, Types of data to script (default is what you want), and everything under Table/View Options.

    That will do what you want. It would take a ton more time to do anything like this by hand.

  • This is what I want and I know how to do this but this procedure is a manual way. I need it automated. I am trying to schedule a task to copy the structure of a database on server A to a database on server B once a month.

    Using the Generate SQL Scripts won't help because if a table is added to database on server A, it won't be copied to server B unless I manually generate a new script.

    jerry-621596 (9/10/2010)


    Really, the easiest way is to right-click the database, select Taks, then click Generate SQL Scripts.

    Make sure and go to the Set Scripting Options page and use Advanced to customize the output.

    Pay special attention to: Script Logins, Script Object-Level Permissions, Types of data to script (default is what you want), and everything under Table/View Options.

    That will do what you want. It would take a ton more time to do anything like this by hand.

  • Are you removing the tables on server b? If not, then the script needs to handle that.

    SQL compare will do this (from my employer): http://www.red-gate.com/products/SQL_Compare/index.htm

    You could also use Powershell to script this out. http://sqlblog.com/blogs/allen_white/archive/2008/01/25/using-powershell-and-sql-server-together.aspx

Viewing 4 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic. Login to reply