Stored procedure

/*----------------------------------------------------------------
This stored procedure has been generated automatically
using StoredProcBuilder (Version 1.0). To get the latest version of
this builder and other downloads, please visit our site
at http://www.ELLKAY.com.
----------------------------------------------------------------*/
CREATE PROCEDURE Ellkay_GetCredentials
as
set nocount on
select UserID,PasswordHash,CreatedTime,LogonFailCount,RequireChangePwd,Disabled,ExpiredTime from [Credentials]
 return

GO

/*----------------------------------------------------------------
This stored procedure has been generated automatically
using StoredProcBuilder (Version 1.0). To get the latest version of
this builder and other downloads, please visit our site
at http://www.ELLKAY.com.
----------------------------------------------------------------*/
CREATE PROCEDURE Ellkay_DeleteCredentials
@tUserID int
 as
set nocount on
Delete  from [Credentials] where UserID =@tUserID
 return

GO



/*
This stored procedure has been generated automatically
using StoredProcBuilder (Version 1.0). To get the latest version of
this builder and other downloads, please visit our site
at http://www.ELLKAY.com.
----------------------------------------------------------------*/
CREATE PROCEDURE Ellkay_SaveCredentials
  @tUserID  varchar(64),
  @tPasswordHash  varchar(40),
  @tCreatedTime  datetime,
  @tLogonFailCount  int,
  @tRequireChangePwd  bit,
  @tDisabled  bit,
  @tExpiredTime  datetime
as
set nocount on
declare @nCount int
select @nCount = (select count(*) from [Credentials]  where UserID = @tUserID)
if (@nCount = 0)
begin
 Insert into [Credentials]
   (UserID,PasswordHash,CreatedTime,LogonFailCount,RequireChangePwd,Disabled,ExpiredTime)
   Values (@tUserID,@tPasswordHash,@tCreatedTime,@tLogonFailCount,@tRequireChangePwd,@tDisabled,@tExpiredTime)
  select @tUserID = @@IDENTITY
 end
 else
 begin
  update [Credentials]  set
  UserID = @tUserID,
  PasswordHash = @tPasswordHash,
  CreatedTime = @tCreatedTime,
  LogonFailCount = @tLogonFailCount,
  RequireChangePwd = @tRequireChangePwd,
  Disabled = @tDisabled,
  ExpiredTime = @tExpiredTime
 where UserID = @tUserID
 end
 return

GO

/*---------------------------------------*/

create proc dbo.dt_whocheckedout
        @chObjectType  char(4),
        @vchObjectName varchar(255),
        @vchLoginName  varchar(255),
        @vchPassword   varchar(255)

as

set nocount on

declare @iReturn int
declare @iObjectId int
select @iObjectId =0

declare @VSSGUID varchar(100)
select @VSSGUID = 'SQLVersionControl.VCS_SQL'

    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
        exec @iReturn = master.dbo.sp_OACreate @VSSGUID, @iObjectId OUT

        if @iReturn <> 0 GOTO E_OAError

        declare @vchReturnValue varchar(255)
        select @vchReturnValue = ''

        exec @iReturn = master.dbo.sp_OAMethod @iObjectId,
            'WhoCheckedOut',
            @vchReturnValue OUT,
            @sProjectName = @vchProjectName,
            @sSourceSafeINI = @vchSourceSafeINI,
            @sObjectName = @vchObjectName,
            @sServerName = @vchServerName,
            @sDatabaseName = @vchDatabaseName,
            @sLoginName = @vchLoginName,
            @sPassword = @vchPassword

        if @iReturn <> 0 GOTO E_OAError

        select @vchReturnValue

    end

CleanUp:
    return

E_OAError:
    exec dbo.dt_displayoaerror @iObjectId, @iReturn
    GOTO CleanUp
GO

你可能感兴趣的:(procedure)