tencent cloud

TencentDB for SQL Server

DocumentaçãoTencentDB for SQL ServerPractical Tutorialtencentdb_ChangeLoginPassword Stored Procedure User Manual

tencentdb_ChangeLoginPassword Stored Procedure User Manual

Download
Modo Foco
Tamanho da Fonte
Última atualização: 2026-08-18 17:38:30
Traduzido por IA

Feature Overview

tencentdb_ChangeLoginPassword is a stored procedure deployed in the master database of a SQL Server instance, enabling users to self-service modify passwords for their SQL Logins. Users can complete password modification without requiring the sysadmin role.

Calling Methods

USE master
GO
EXEC dbo.tencentdb_ChangeLoginPassword
@login = N'<target_login_name>',
@new_password = N'<new_password>'

Parameter Description

Parameter
Type
Description
@login
SYSNAME
SQL Login name for which the password is to be changed
@new_password
NVARCHAR(128)
New Password

Returned values

Return Code
Description
0
Successful
51001
The login name is in the system blocklist.
51002
The login name does not exist or is not an SQL Login.
51004
Modification of sa (system built-in privileged account) is not allowed.
51006
The password contains special characters prohibited by the server security policy.
51007
The target login name is a member of a privileged server role (sysadmin/securityadmin/serveradmin).
51008
The password does not meet the complexity requirements.
51009
Password length exceeds the limit (> 32 characters).

Password Complexity Requirements

Rule
Requirement
Length
8 to 32 characters
Complexity
Contain at least 2 types from letters, numbers, and symbols
Excluding account name
The password must not contain the login name (case-insensitive).
Special character restriction
Must not contain special character combinations such as ];, [;, ;[, '], [', and so on

Call Example

-- Password successfully changed.
EXEC dbo.tencentdb_ChangeLoginPassword @login = N'myapp_user', @new_password = N'NewP@ss2026!'
-- Returns 0

-- Attempt to modify a system account (denied)
EXEC dbo.tencentdb_ChangeLoginPassword @login = N'tencent_admin', @new_password = N'Test1234!'
-- Msg 51001: Login is in the system blacklist and cannot be modified.

-- Password does not meet complexity requirements (denied)
EXEC dbo.tencentdb_ChangeLoginPassword @login = N'myapp_user', @new_password = N'123'
-- Msg 51008: Password does not meet complexity requirements.

Note

Applicable only to SQL Logins: Windows Authentication accounts are not supported for password modification through this stored procedure.
Privileged account modification not supported: Members of the sysadmin/securityadmin/serveradmin roles are not permitted to modify passwords.
EXECUTE permission required: Your account must have EXECUTE permission on this stored procedure to invoke it.
Execute in the master database: Before invoking, first run USE master.

Ajuda e Suporte

Esta página foi útil?

comentários