# Procedure: sp_upgraddiagrams

## Properties

Property | Value
--- | ---
Name | sp_upgraddiagrams
ID | 1511676433
Schema | dbo
Owner | dbo
Type | SQL STORED PROCEDURE
Execute As | Caller
Encrypted |
ANSI NULLS |
Uses Quoted Identifier |
Published |
Schema Published |
Execution Replicated |
Replication Serializable Only |
Skips Replication Constraints |
Is Recompiled |
Uses Database Collation |
Null on Null Input |
MS Shipped |
Modify Date | 6/20/2011 3:15:59 PM
Create Date | 6/20/2011 3:15:59 PM

## Extended Properties

No extended properties defined.

## Permissions

No object level permissions defined.

## Parameters

No procedure parameters defined.

## Objects that depend on [sp_upgraddiagrams]

- dbo.sp_upgraddiagrams

## Objects on which [sp_upgraddiagrams] depends

- dbo.sp_upgraddiagrams
  - dbo.dtproperties
  - dbo.sysdiagrams

## SQL

Script
SET ANSI_NULLS ON SET QUOTED_IDENTIFIER ON CREATE PROCEDURE dbo.sp_upgraddiagrams AS BEGIN IF OBJECT_ID(N'dbo.sysdiagrams') IS NOT NULL return 0; CREATE TABLE dbo.sysdiagrams ( name sysname NOT NULL, principal_id int NOT NULL, -- we may change it to varbinary(85) diagram_id int PRIMARY KEY IDENTITY, version int, definition varbinary(max) CONSTRAINT UK_principal_name UNIQUE ( principal_id, name ) ); /* Add this if we need to have some form of extended properties for diagrams */ /* IF OBJECT_ID(N'dbo.sysdiagram_properties') IS NULL BEGIN CREATE TABLE dbo.sysdiagram_properties ( diagram_id int, name sysname, value varbinary(max) NOT NULL ) END */ IF OBJECT_ID(N'dbo.dtproperties') IS NOT NULL begin insert into dbo.sysdiagrams ( [name], [principal_id], [version], [definition] ) select convert(sysname, dgnm.[uvalue]), DATABASE_PRINCIPAL_ID(N'dbo'), -- will change to the sid of sa 0, -- zero for old format, dgdef.[version], dgdef.[lvalue] from dbo.[dtproperties] dgnm inner join dbo.[dtproperties] dggd on dggd.[property] = 'DtgSchemaGUID' and dggd.[objectid] = dgnm.[objectid] inner join dbo.[dtproperties] dgdef on dgdef.[property] = 'DtgSchemaDATA' and dgdef.[objectid] = dgnm.[objectid] where dgnm.[property] = 'DtgSchemaNAME' and dggd.[uvalue] like N'_EA3E6268-D998-11CE-9454-00AA00A3F36E_' return 2; end return 1; END EXEC sys.sp_addextendedproperty @name=N'microsoft_database_tools_support', @value=1 , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'PROCEDURE',@level1name=N'sp_upgraddiagrams'

#### See also

List of Procedures