3

Is there a tool that will let me generate a single script containing all tables and views? Sql Publishing Wizard drops everything (so all data is lost) and recreates it. It does have an option to not drop, but in that case, it doesn't update tables that exist (if any columns have changed).

0

6 Answers 6

4

In SQL Server Management Studio 2008 you can right-click on a database in the object explorer, go to Tasks > Generate Scripts..., and that will give you the option to choose not only what object types you want to script, but whether or not you want to script the drop as well.

Sign up to request clarification or add additional context in comments.

1 Comment

+1 because scripting is a task that can be done right in SSMS, no need for an outside tool.
2

When you are making changes to existing tables, you should be writing alter table scripts to make the change and then putting them in source control like any other code. Then when you deploy a set of changes, you run the scripts you created for that deployment.

Otherwise, yes use SQL compare.

Comments

1

Should you look at the Red Gate products specifically SQL Compare. They'll handle any situation you could need concerning script generation and database synchronization. (You can get a trial license too, to try it out and see if it is what you need.)

1 Comment

compare and datacompare are awesome. off topic, sql comes with a utility called tablediff.exe as well.
1

Have a look at this tool can be used which has the capability to generate the create and drop scripts for the SQL server objects, provided in a configuration file.

This tool uses the same mechanism as SSMS tool uses to generate the script.

SQL Server Script Generator Tool (via C#)

Comments

0

Have a look at these:
WinSQL (Lite edition is free, other versions are reasonably priced + free trial)
OpenDbDiff (free)

Comments

0

You can also check out MyDbUtils which can create scripts for:

  • Stored Procedures
  • Functions
  • Views
  • Triggers

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.