I need to create a SQL script to generate a Database diagram.

It should accept two parameters:

  1. DB name
  2. Schema

It should create a database diagram in Database Diagrams folder with the underlying tables in the given schema.

I am trying to find the system stored procedure which is being called when we create it by UI.

Please suggest some approach to accomplish this task.

1 Answer 1


Can you set up some extended event captures or profile traces to capture what happens when you use SSMS to see if you can replicate it via scripts.

or https://stackoverflow.com/questions/18246965/how-can-i-script-sql-server-database-diagrams

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.