Sunday, January 2, 2011

T-SQL Copy database diagrams to another database

Unlike stored procedure, functions, tables, views, ... MS Sql server doesn't have an easy way to script or create database diagrams. It keeps all the diagrams in [sysdiagrams] system table.

SELECT *
FROM sysdiagrams

USE newDb
GO

INSERT INTO sysdiagrams
([name], pricipal_id, version, definition)
SELECT [name], pricipal_id, version, definition
FROM #tempDiagrams

Share/Bookmark

No comments: