procedures key icon Procedure: sp_creatediagram

Properties

Property Value
Name sp_creatediagram
ID 1639676889
Schema dbo
Owner dbo
Type SQL STORED PROCEDURE
Execute As dbo
Encrypted false
ANSI NULLS true
Uses Quoted Identifier true
Published false
Schema Published false
Execution Replicated false
Replication Serializable Only false
Skips Replication Constraints false
Is Recompiled false
Uses Database Collation false
Null on Null Input false
MS Shipped false
Modify Date 6/20/2011 3:16:00 PM
Create Date 6/20/2011 3:16:00 PM

Extended Properties

No extended properties defined.

Permissions

Permissions for: guest

Permission Grantor Grant With Grant Option Deny
Alter
Control
Execute dbo true
Take Ownership
View Definition

Permissions for: public

Permission Grantor Grant With Grant Option Deny
Alter
Control
Execute dbo true
Take Ownership
View Definition

Parameters

Parameter Name Datatype Output Cursor Ref Readonly Has Default Value Default Value Xml Collection Name Description
@diagramname sysname false false false false
@owner_id int false false false false
@version int false false false false
@definition varbinary(max) false false false false

Objects that depend on [sp_creatediagram]

Objects on which [sp_creatediagram] depends

SQL

Script
SET ANSI_NULLS ON
SET QUOTED_IDENTIFIER ON
CREATE PROCEDURE dbo.sp_creatediagram ( @diagramname sysname, @owner_id int = null, @version int, @definition varbinary(max) ) WITH EXECUTE AS 'dbo' AS BEGIN set nocount on declare @theId int declare @retval int declare @IsDbo int declare @userName sysname if(@version is null or @diagramname is null) begin RAISERROR (N'E_INVALIDARG', 16, 1); return -1 end execute as caller; select @theId = DATABASE_PRINCIPAL_ID(); select @IsDbo = IS_MEMBER(N'db_owner'); revert; if @owner_id is null begin select @owner_id = @theId; end else begin if @theId <> @owner_id begin if @IsDbo = 0 begin RAISERROR (N'E_INVALIDARG', 16, 1); return -1 end select @theId = @owner_id end end -- next 2 line only for test, will be removed after define name unique if EXISTS(select diagram_id from dbo.sysdiagrams where principal_id = @theId and name = @diagramname) begin RAISERROR ('The name is already used.', 16, 1); return -2 end insert into dbo.sysdiagrams(name, principal_id , version, definition) VALUES(@diagramname, @theId, @version, @definition) ; select @retval = @@IDENTITY return @retval 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_creatediagram'

See also

List of Procedures