| Property | Value |
|---|---|
| Name | sp_alterdiagram |
| ID | 1671677003 |
| Schema | dbo |
| Owner | dbo |
| Type | SQL STORED PROCEDURE |
| Execute As | dbo |
| 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:16:00 PM |
| Create Date | 6/20/2011 3:16:00 PM |
| Permission | Grantor | Grant | With Grant Option | Deny |
|---|---|---|---|---|
| Alter | ||||
| Control | ||||
| Execute | dbo |
|
||
| Take Ownership | ||||
| View Definition |
| Permission | Grantor | Grant | With Grant Option | Deny |
|---|---|---|---|---|
| Alter | ||||
| Control | ||||
| Execute | dbo |
|
||
| Take Ownership | ||||
| View Definition |
| Parameter Name | Datatype | Output | Cursor Ref | Readonly | Has Default Value | Default Value | Xml Collection Name | Description |
|---|---|---|---|---|---|---|---|---|
| @diagramname | sysname |
|
|
|
|
|||
| @owner_id | int |
|
|
|
|
|||
| @version | int |
|
|
|
|
|||
| @definition | varbinary(max) |
|
|
|
|
| Script |
|---|
| SET ANSI_NULLS ON SET QUOTED_IDENTIFIER ON CREATE PROCEDURE dbo.sp_alterdiagram ( @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 @UIDFound int declare @DiagId int declare @ShouldChangeUID int if(@diagramname is null) begin RAISERROR ('Invalid ARG', 16, 1) return -1 end execute as caller; select @theId = DATABASE_PRINCIPAL_ID(); select @IsDbo = IS_MEMBER(N'db_owner'); if(@owner_id is null) select @owner_id = @theId; revert; select @ShouldChangeUID = 0 select @DiagId = diagram_id, @UIDFound = principal_id from dbo.sysdiagrams where principal_id = @owner_id and name = @diagramname if(@DiagId IS NULL or (@IsDbo = 0 and @theId <> @UIDFound)) begin RAISERROR ('Diagram does not exist or you do not have permission.', 16, 1); return -3 end if(@IsDbo <> 0) begin if(@UIDFound is null or USER_NAME(@UIDFound) is null) -- invalid principal_id begin select @ShouldChangeUID = 1 ; end end -- update dds data update dbo.sysdiagrams set definition = @definition where diagram_id = @DiagId ; -- change owner if(@ShouldChangeUID = 1) update dbo.sysdiagrams set principal_id = @theId where diagram_id = @DiagId ; -- update dds version if(@version is not null) update dbo.sysdiagrams set version = @version where diagram_id = @DiagId ; return 0 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_alterdiagram' |