0

I know script generation can be achieved with the wizard provided by the management studio. In fact, this other question's accepted answer in SO is a great example: How to Generate Scripts For All Triggers in Database Using Microsoft SQL Server Management Studio

My question is wheter I can achieve the same results (as I would get from the wizard) from executing some script or command from a query window, and if positive, how could I do it.

EDIT: In case it matters, I'm working with sql server CE 2012 and its respective ssms

Community
  • 1
  • 1
  • What objects are you trying to script? – Raj Sep 08 '14 at 10:23
  • @raj My goal is to make nine scripts: four for dropping stored procedures, views tables and schemas, four for creating schemas, tables, views and stored procedures and one for inserting predefined needed configuration data into a few tables, and, if posible, avoid going to the wizard every time since the data structure is still changing. All I want to have an updated version of the scripts everytime in a quick way (wizards are great but speed of use is normally not one of their most notable features). – Enlacumbre Sep 08 '14 at 10:59
  • How about creating a database project in Visual Studio and deploying it, each time you make changes? – Raj Sep 08 '14 at 11:01
  • @Raj That could be a solution for now, until the aplication goes into production (and it will soon). At that point I'll have several standalone applications with their respective database file and their own generated data and I think it might not be the best approach. – Enlacumbre Sep 08 '14 at 11:08

2 Answers2

0

If I found out your question correctly in every window in SQL Server management you can get script of operation of page

For example make index on column of table, Instead of click OK you can get script of command by clicking on script button
https://i.stack.imgur.com/Mi0Yq.png

AmanVirdi
  • 1,667
  • 2
  • 22
  • 32
jaafar
  • 1
  • 1
  • I think what you suggest aplies only for common tasks like adding a column to a table, or creating some relationship from the design mode, unfortunately in this case that option is not available – Enlacumbre Sep 08 '14 at 10:50
0

After some more research, and even though I did not find exactly what I was looking for, I managed to find something that covered my needs, thanks to this posts: - Generate SQL server scripts from command line? - Script entire database SQL-Server - https://dba.stackexchange.com/questions/56616/sql-server-2012-generate-scripts-from-command-line

From the varied options the answers in them offer, I ended up using Schemazen (https://github.com/sethreno/schemazen), that did what I needed quick and easy.

Community
  • 1
  • 1