康柏仕电脑学院正航ERP软件产品技术分享区Server服务器配置教程 → sql server 错误2812 :未能找到存储过程'sp_password' 解决方法!


  共有16378人关注过本帖树形打印复制链接

主题:sql server 错误2812 :未能找到存储过程'sp_password' 解决方法!

帅哥哟,离线,有人找我吗?
轻轻风聆
  1楼 | QQ | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信 家人主人
等级:管理员 帖子:2683 积分:26232 威望:0 精华:14 注册:2005/9/15
sql server 错误2812 :未能找到存储过程'sp_password' 解决方法!  发帖心情 Post By:2012/5/16 12:20:12 [只看该作者]

现在有很多自动扫描1433端口的软件,会破坏sp_password标。造成在修改SA密码的时候出现2812错误

下边是解决代码,用WINDOWS身份验证登陆到SQL SERVER的查询工具。复制--粘贴--执行就OK拉。

 

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

 

以上代码在SQL 2000 SP4上测试通过,在2005暂没测试。有测试成功的,上来说下!



正航--放大你管理的力量!
正航,缔造智慧企业!
正航东莞-松山湖、长安:www.chidg.com
咨询热线:0769-81158210  13580877608
 回到顶部