USE [Vertragsverwaltung_20160404] GO /****** Object: StoredProcedure [dbo].[dt_checkoutobject] Script Date: 02.12.2016 09:08:54 ******/ DROP PROCEDURE [dbo].[dt_checkoutobject] GO /****** Object: StoredProcedure [dbo].[dt_checkoutobject] Script Date: 02.12.2016 09:08:54 ******/ SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER OFF GO create proc [dbo].[dt_checkoutobject] @chObjectType char(4), @vchObjectName varchar(255), @vchComment varchar(255), @vchLoginName varchar(255), @vchPassword varchar(255), @iVCSFlags int = 0, @iActionFlag int = 0/* 0 => Checkout, 1 => GetLatest, 2 => UndoCheckOut */ as set nocount on declare @iReturn int declare @iObjectId int select @iObjectId =0 declare @VSSGUID varchar(100) select @VSSGUID = 'SQLVersionControl.VCS_SQL' declare @iReturnValue int select @iReturnValue = 0 declare @vchTempText varchar(255) /* this is for our strings */ declare @iStreamObjectId int select @iStreamObjectId = 0 declare @iPropertyObjectId int select @iPropertyObjectId = (select objectid from dbo.dtproperties where property = 'VCSProjectID') declare @vchProjectName varchar(255) declare @vchSourceSafeINI varchar(255) declare @vchServerName varchar(255) declare @vchDatabaseName varchar(255) exec dbo.dt_getpropertiesbyid_vcs @iPropertyObjectId, 'VCSProject', @vchProjectName OUT exec dbo.dt_getpropertiesbyid_vcs @iPropertyObjectId, 'VCSSourceSafeINI', @vchSourceSafeINI OUT exec dbo.dt_getpropertiesbyid_vcs @iPropertyObjectId, 'VCSSQLServer', @vchServerName OUT exec dbo.dt_getpropertiesbyid_vcs @iPropertyObjectId, 'VCSSQLDatabase', @vchDatabaseName OUT if @chObjectType = 'PROC' begin /* Procedure Can have up to three streams Drop Stream, Create Stream, GRANT stream */ exec @iReturn = master.dbo.sp_OACreate @VSSGUID, @iObjectId OUT if @iReturn <> 0 GOTO E_OAError exec @iReturn = master.dbo.sp_OAMethod @iObjectId, 'CheckOut_StoredProcedure', NULL, @sProjectName = @vchProjectName, @sSourceSafeINI = @vchSourceSafeINI, @sObjectName = @vchObjectName, @sServerName = @vchServerName, @sDatabaseName = @vchDatabaseName, @sComment = @vchComment, @sLoginName = @vchLoginName, @sPassword = @vchPassword, @iVCSFlags = @iVCSFlags, @iActionFlag = @iActionFlag if @iReturn <> 0 GOTO E_OAError exec @iReturn = master.dbo.sp_OAGetProperty @iObjectId, 'GetStreamObject', @iStreamObjectId OUT if @iReturn <> 0 GOTO E_OAError create table #commenttext (id int identity, sourcecode varchar(255)) select @vchTempText = 'STUB' while @vchTempText is not null begin exec @iReturn = master.dbo.sp_OAMethod @iStreamObjectId, 'GetStream', @iReturnValue OUT, @vchTempText OUT if @iReturn <> 0 GOTO E_OAError if (@vchTempText = '') set @vchTempText = null if (@vchTempText is not null) insert into #commenttext (sourcecode) select @vchTempText end select 'VCS'=sourcecode from #commenttext order by id select 'SQL'=text from syscomments where id = object_id(@vchObjectName) order by colid end CleanUp: return E_OAError: exec dbo.dt_displayoaerror @iObjectId, @iReturn GOTO CleanUp GO