简体   繁体   中英

How to transfer SQL Server DB structure to another server

Tell me please what's the best way to copy db structure to another server?

I'm trying to generate a script in Management Studio and then run that script on the remote machine. And I hate that thing. It works unpredictable, you have to fix manually a lot of crap in the generated script. I guess that isn't the best solution.

Then I tried to generate SSIS package with DTSWizard.exe but I know nothing about that stuff, and I couldn't find a way to copy only the structure without data.

Maybe there is a way somehow to break entire db structure into smaller pieces and work with them - first do all the tables, then views, then functions etc.

Or there is another, normal way to do that without so much headache?

Generating a script is the best solution. If you have to fix it manually, you are scripting it incorrectly. Use the "Generate Scripts..." task in Management Studio

Be sure to check:

  1. Are you generating the script for the appropriate version?
  2. Are you specifying "DROP and CREATE" and "IF EXISTS" options if running on an earlier version of the db?
  3. Are you scripting all the auxiliary objects (users, triggers, indexes, etc?)

如果可以使用第三方工具,那么Red Gate SQL Compare是一个不错的工具。

Try DBSourceTools. ( http://dbsourcetools.codeplex.com )
Its open source, and specifically designed to script an entire database - tables, views, procs to disk, and then re-create that database through a deployment target.
You can script all data, or just specify which tables to script data for.
Additionally, you can zip up the results for distribution.
We use it for source control of databases, and to test update patches for new releases.
In the back-end it's built around SMO, and thus supports SQL 2000, 2005 and 2008.
DBDiff is integrated, to allow for schema comparisons.
Have fun, - Nathan.

尝试使用SQL Examiner Suite: http : //www.sqlaccessories.com/SQL_Examiner_Suite/-您可以使用此工具复制架构和数据

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM