-1

I'm currently in need of a way to pragmatically generate DDL scripts for a single database in SQL Server. My current need is to do this in 2012, but it's likely I'll need to be able to do this with 2008 - 2017.

I've seen this question (and answers) SQL Server 2012: Generate Scripts from command line

as well as this one https://stackoverflow.com/questions/483568/how-can-i-automate-the-generate-scripts-task-in-sql-server-management-studio-2

I'm trying to figure out the best way to do this today. I realize this may seem like a duplicate, especially if there's an answer out there that is the best way to do it today (and maybe I just don't realize it).

The simple version of the question:

In SQL Server 2012, what's the best way, that I can schedule, to produce all the DDL needed to make an exact replica of a database?

Mic
  • 3
  • 1
  • I understand that this was closed as a duplicate. It's pretty frustrating that it got closed as a duplicate of a question that I linked (and obviously found to be lacking the answer to my question). I think that the answer I did receive is helpful, and that this question existing would help other people like me in the future when they are looking for the same information as me and would like to make sure the 6 year old answer is still valid. – Mic May 26 '20 at 13:04

1 Answers1

1

SMO is still the gold standard for scripting. It's what SSMS uses internally, and you can use it from .NET or PowerShell.

David Browne - Microsoft
  • 46,306
  • 3
  • 46
  • 96