sql2000提示缺少sp_password存储过程解决

在企业管理器里面选择master数据库,然后执行如下sql语句



create PROCEDURE [sp_password]
@old [sysname],
@new [sysname],
@loginame [sysname]
AS
-- SETUP RUNTIME OPTIONS / DECLARE VARIABLES --
set nocount on
    declare @self int
    select @self = CASE WHEN @loginame is null THEN 1 ELSE 2 END


    -- RESOLVE LOGIN NAME
    if @loginame is null
        select @loginame = suser_sname()


    -- CHECK PERMISSIONS (SecurityAdmin per Richard Waymire) --
IF (not is_srvrolemember('securityadmin') = 1)
        AND not @self = 1
begin
  dbcc auditevent (107, @self, 0, @loginame, NULL, NULL, NULL)
  raiserror(15210,-1,-1)
  return (1)
end
ELSE
begin
  dbcc auditevent (107, @self, 1, @loginame, NULL, NULL, NULL)
end


    -- DISALLOW USER TRANSACTION --
set implicit_transactions off
IF (@@trancount > 0)
begin
raiserror(15002,-1,-1,'sp_password')
return (1)
end


    -- RESOLVE LOGIN NAME (disallows nt names)
    if not exists (select * from master.dbo.syslogins where
                    loginname = @loginame and isntname = 0)
begin
raiserror(15007,-1,-1,@loginame)
return (1)
end


-- IF non-SYSADMIN ATTEMPTING CHANGE TO SYSADMIN, REQUIRE PASSWORD (218078) --
if (@self <> 1 AND is_srvrolemember('sysadmin') = 0 AND exists
(SELECT * FROM master.dbo.syslogins WHERE loginname = @loginame and isntname = 0
AND sysadmin = 1) )
SELECT @self = 1


    -- CHECK OLD PASSWORD IF NEEDED --
    if (@self = 1 or @old is not null)
        if not exists (select * from master.dbo.sysxlogins
                        where srvid IS NULL and
     name = @loginame and
                 ( (@old is null and password is null) or
                              (pwdcompare(@old, password, (CASE WHEN xstatus&2048 = 2048 THEN 1 ELSE 0 END)) = 1) )   )
        begin
   raiserror(15211,-1,-1)
   return (1)
   end


    -- CHANGE THE PASSWORD --
    update master.dbo.sysxlogins
set password = convert(varbinary(256), pwdencrypt(@new)), xdate2 = getdate(), xstatus = xstatus & (~2048)
where name = @loginame and srvid IS NULL


-- UPDATE PROTECTION TIMESTAMP FOR MASTER DB, TO INDICATE SYSLOGINS CHANGE --
exec('use master grant all to null')


    -- FINALIZATION: RETURN SUCCESS/FAILURE --
if @@error <> 0
        return (1)
    raiserror(15478,-1,-1)
return  (0) -- sp_password
GO


重新启动数据库即可。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值