📄 20065805031存储过程范本.txt
字号:
create proc dbo.dt_addtosourcecontrol
@vchSourceSafeINI varchar(255) = '',
@vchProjectName varchar(255) ='',
@vchComment varchar(255) ='',
@vchLoginName varchar(255) ='',
@vchPassword varchar(255) =''
as
set nocount on
declare @iReturn int
declare @iObjectId int
select @iObjectId = 0
declare @iStreamObjectId int
select @iStreamObjectId = 0
declare @VSSGUID varchar(100)
select @VSSGUID = 'SQLVersionControl.VCS_SQL'
declare @vchDatabaseName varchar(255)
select @vchDatabaseName = db_name()
declare @iReturnValue int
select @iReturnValue = 0
declare @iPropertyObjectId int
declare @vchParentId varchar(255)
declare @iObjectCount int
select @iObjectCount = 0
exec @iReturn = sp_OACreate @VSSGUID, @iObjectId OUT
if @iReturn <> 0 GOTO E_OAError
/* Create Project in SS */
exec @iReturn = sp_OAMethod @iObjectId,
'AddProjectToSourceSafe',
NULL,
@vchSourceSafeINI,
@vchProjectName output,
@@SERVERNAME,
@vchDatabaseName,
@vchLoginName,
@vchPassword,
@vchComment
if @iReturn <> 0 GOTO E_OAError
exec @iReturn = sp_OAGetProperty @iObjectId, 'GetStreamObject', @iStreamObjectId OUT
if @iReturn <> 0 GOTO E_OAError
/* Set Database Properties */
begin tran SetProperties
/* add high level object */
exec @iPropertyObjectId = dbo.dt_adduserobject_vcs 'VCSProjectID'
select @vchParentId = CONVERT(varchar(255),@iPropertyObjectId)
exec dbo.dt_setpropertybyid @iPropertyObjectId, 'VCSProjectID', @vchParentId , NULL
exec dbo.dt_setpropertybyid @iPropertyObjectId, 'VCSProject' , @vchProjectName , NULL
exec dbo.dt_setpropertybyid @iPropertyObjectId, 'VCSSourceSafeINI' , @vchSourceSafeINI , NULL
exec dbo.dt_setpropertybyid @iPropertyObjectId, 'VCSSQLServer', @@SERVERNAME, NULL
exec dbo.dt_setpropertybyid @iPropertyObjectId, 'VCSSQLDatabase', @vchDatabaseName, NULL
if @@error <> 0 GOTO E_General_Error
commit tran SetProperties
declare cursorProcNames cursor for
select convert(varchar(255), name) from sysobjects where type = 'P' and name not like 'dt_%'
open cursorProcNames
while 1 = 1
begin
declare @vchProcName varchar(255)
fetch next from cursorProcNames into @vchProcName
if @@fetch_status <> 0
break
select colid, text into #ProcLines
from syscomments
where id = object_id(@vchProcName)
order by colid
declare @iCurProcLine int
declare @iProcLines int
select @iCurProcLine = 1
select @iProcLines = (select count(*) from #ProcLines)
while @iCurProcLine <= @iProcLines
begin
declare @pos int
select @pos = 1
declare @iCurLineSize int
select @iCurLineSize = len((select text from #ProcLines where colid = @iCurProcLine))
while @pos <= @iCurLineSize
begin
declare @vchProcLinePiece varchar(255)
select @vchProcLinePiece = convert(varchar(255),
substring((select text from #ProcLines where colid = @iCurProcLine),
@pos, 255 ))
exec @iReturn = sp_OAMethod @iStreamObjectId, 'AddStream', @iReturnValue OUT, @vchProcLinePiece
if @iReturn <> 0 GOTO E_OAError
select @pos = @pos + 255
end
select @iCurProcLine = @iCurProcLine + 1
end
drop table #ProcLines
exec @iReturn = sp_OAMethod @iObjectId,
'CheckIn_StoredProcedure',
NULL,
@sProjectName = @vchProjectName,
@sSourceSafeINI = @vchSourceSafeINI,
@sServerName = @@SERVERNAME,
@sDatabaseName = @vchDatabaseName,
@sObjectName = @vchProcName,
@sComment = @vchComment,
@sLoginName = @vchLoginName,
@sPassword = @vchPassword,
@iVCSFlags = 0,
@iActionFlag = 0,
@sStream = ''
if @iReturn = 0 select @iObjectCount = @iObjectCount + 1
end
CleanUp:
close cursorProcNames
deallocate cursorProcNames
select @vchProjectName
select @iObjectCount
return
E_General_Error:
/* this is an all or nothing. No specific error messages */
goto CleanUp
E_OAError:
exec dbo.dt_displayoaerror @iObjectId, @iReturn
goto CleanUp
GO
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -