SQL Clone
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 

Get your favorite SSC scripts directly in SSMS with the free SQL Scripts addin. Search for scripts directly from SSMS, and instantly access any saved scripts in your SSC briefcase from the favorites tab.
Download now (direct download link)

Export diagrams

By Jonas Gunnarsson,

The script generates an import script for SQL Server Management Studio diagrams.
Easy to use, exports all diagrams in current database, to a script. Tip: Place it in your repository.

Remarks

The name of diagrams need to be unique in database. The script replace an existing diagram.

Verify existing diagram names first! List the database diagram(s) for current database:

select [name] from dbo.sysdiagrams;

Usage

Run the script against a database and select Results to File.

To restore diagram(s), to another database, just run the saved file.

Note
Objects required to use database diagrams is added for owner, when clicking on folder Database Diagrams in SSMS.

Further reading

Revisions

  • 1.0 2018-05-25 First version
  • 1.1 2018-09-11 Replace existing diagram
  • 1.2 2018-11-09 Skip the use dbName line, so restore can be done to any database.

Total article views: 490 | Views in the last 30 days: 21
 
Related Articles
FORUM

Database diagrams

Database diagrams

SCRIPT

Generate scripts for SQL Server Management Studio diagrams

The procedure generates an import script of diagrams.

ARTICLE

Database Modeling and Diagrams with SQL Server 2008

How to use Database Diagram tool in SQL SERVER.

FORUM

Database Diagram

Facing Problem with Database Diagram

SCRIPT

Script out EXISTING database mail profile's settings

Script out EXISTING database mail profile settings

Tags
diagram    
 
Contribute