• 修改SQL的sa密码时提示“2812:未能找到存储过程‘sp_password’”的解决办法


    在“企业管理器”-“安全性”-“登录”里面对sa修改密码时,弹出错误提示:

    2812:未能找到存储过程‘sp_password’

    按照此错误信息应该就是系统缺少‘sp_password’这个存储过程,所以只要给系统添加这个存储过程就可以了,具解决方式如下:

    打开“查询分析器”,登录的时候选择“Windows验证”而非默认的“SQL Server身份验证”,在master下执行以下语句:

    SET QUOTED_IDENTIFIER ON  
    GO  
    SET ANSI_NULLS OFF  
    GO  
    create procedure sp_password  
        @old sysname = NULL,        -- the old (current) password 
        @new sysname,               -- the new password  
        @loginame sysname = NULL    -- user to change password on 
    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  
    SET QUOTED_IDENTIFIER OFF  
    GO  
    SET ANSI_NULLS ON  
    GO  

    执行完此查询后,sa的密码就可以修改了。

    注:请自行谨慎操作!!事先备份数据库!!

    出现2812这个错误提示,应该是说sp_password这个东西不存在,而以上的语句,就是创建sp_password这个东西。

    如果执行上面语句的时候出现错误:

    未启用对系统目录的特殊更新。系统管理员必须重新配置 SQL Server 以允许这种操作。

    解决方法:企业管理器——>工具——>SQL Server 配置属性——>服务器设置——>允许对系统目录直接进行修改,然后重新执行上面的语句。

  • 相关阅读:
    [Functional Programming] Building a Timer UI by Composing Callbacks
    [Debug] Use Chrome DevTools console utilities to make debugging easier
    [Debug] Copy a network request as fetch or cURL with Chrome DevTools
    [CSS] Use CSS Variables with Calc and HSL to Implement Dark Mode
    [Kotlin] Adding functions to existing classes (extension functions)
    [Kotlin] Unit testing throws exception
    [Kotlin] Try resource, use {} block
    少儿编程教学环境开发之架构选型篇
    分布式系统理论之Quorum机制
    存储基本概念(lun,volume,HBA,DAS,NAS,SAN,iSCSI,IPSAN)
  • 原文地址:https://www.cnblogs.com/fm168/p/2957576.html
Copyright © 2020-2023  润新知