1

Every time I want to create a script of the database structure (and data) of our deployment database (a brand new database with the software's basic data), I have go to SSMS, select the database, Tasks -> Scripts -> Generate Scripts. Then I have a very specific setting which I have to change every single time to the same values.

This is very time consuming and looks like a task that could very well be automated. Is it possible to automate this task from within SSMS, with my specific settings? If not, is there a way to automate it outside SSMS? I do not discard writing a C# console program to perform that, this task is not for the final user it's for our labs.

UPDATE

The objective here, as usual, is getting the solution which will take less time. So, before I got to the C# coding level, I would like to try automating the existing tools. The order would be:

  1. Can I automate from SSMS?
  2. Can I automate by running a outside script?
  3. How can I automate with C# coding? (the learning resources were pointed out by Nicholas Carey)

2 Answers 2

2

What are you using the script for? (I can think of backup, release versioning, source control for logging each change)

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

1 Comment

The general objective is both release versioning and source control, but I already manage to do it using SVN. This is our deployment database, so it contains the structure and the basic data to get started. The only thing is that I would like to automate the processes. I just thought there might be a way to save my settings. I lose 2-3 minutes a day on that, so I don't think it's worth writing a C# program using SMO (maybe later). But you gave a good overview of the options.
0

Look at SMO: http://msdn.microsoft.com/en-us/library/ms162169(v=SQL.100).aspx

Then script your database, put the scripts in source control and require that changes be made via scripts.

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.