tencent cloud

TencentDB for SQL Server

Configuring Instance Parameters

Baixar
Modo Foco
Tamanho da Fonte
Última atualização: 2026-11-19 18:03:45
Traduzido por IA

Feature Overview

sp_rds_configure is a stored procedure deployed in the master database of a TencentDB for SQL Server instance. It allows you to self-service configure instance-level parameters after directly connecting to the instance through client tools such as SSMS. Users can configure advanced parameters without having the sysadmin role or manually enabling show advanced options.
For more information about SQL Server server configuration options, see Microsoft official documentation: Server Configuration Options.

Supported Instances

Instance Architectures: single-node, two-node, multi-node, and read-only instances.
Instance Version: SQL Server 2008 R2 or later.

Calling Methods

EXEC sp_rds_configure @config_name = N'<parameter item>', @config_value = <parameter value>
GO
Note:
This stored procedure starts with sp_ and is deployed in the master database. When SQL Server cannot find it in the current database, it automatically resolves it from the master database. Therefore, you can directly run EXEC sp_rds_configure in any database without USE master.

Parameter Description

Parameter
Type
Required or Not
Description
@config_name
NVARCHAR(128)
Yes
The name of the instance configuration parameter to set must be exactly the same as the name in Supported Parameters (case-insensitive, but spaces and parentheses must be retained).
@config_value
BIGINT
Yes
The target value of this parameter must be within the allowed value range of the parameter.

Supported Parameters

The current stored procedure provides the following 15 parameters. The "Effective Method" column in the table indicates whether a restart is required after modification, and the "Example" column provides ready-to-use commands that can be copied and executed directly.
Note:
For quick reference, the "Example" column in the following table uses the positional parameter shorthand (omitting the @config_name and @config_value parameter names), which can be copied and executed directly in any database. For the complete syntax, see Call Examples.
Parameter
Description
Value Range
Default Value
Option
Use Example
fill factor (%)
Specifies the default fill factor percentage for index pages when an index is created, used to fine-tune the storage and performance of index data. 0 indicates using the server default behavior (equivalent to 100%).
[0, 100]
0
Instance restart required
Set the fill factor to 90%:
EXEC sp_rds_configure N'fill factor (%)', 90;
max worker threads
Specifies the maximum number of worker threads available across the entire SQL Server instance for processing query requests, logins, logouts, and similar application requests. 0 indicates that SQL Server automatically configures the value based on the number of logical CPUs.
0 or [128, 65535]
0
Immediately effective
Set the maximum worker threads to 1000:
EXEC sp_rds_configure N'max worker threads', 1000;
user connections
Specifies the maximum number of concurrent user connections allowed. 0 indicates no limit (dynamically managed by SQL Server).
[0, 32767]
0
Instance restart required
Limit the maximum number of concurrent connections to 500:
EXEC sp_rds_configure N'user connections', 500;
remote proc trans
Specifies the transaction for protecting cross-server remote stored procedure calls through MS DTC (that is, whether to promote remote procedure calls to distributed transactions). Values: 0 disables it; 1 enables it.
[0, 1]
0
Immediately effective
Enable remote procedure distributed transactions:
EXEC sp_rds_configure N'remote proc trans', 1;
cost threshold for parallelism
Specifies the cost threshold for SQL Server to create and run parallel query plans, measured in optimizer-estimated cost units.
[0, 32767]
5
Immediately effective
Set the cost threshold for parallelism to 30:
EXEC sp_rds_configure N'cost threshold for parallelism', 30;
max degree of parallelism
Specifies the maximum number of processors used to run a single statement during each parallel plan execution (max degree of parallelism). 0 indicates using all available CPUs of the instance; 1 indicates disabling parallel plans.
[0, 32767]
0
Immediately effective
Set the maximum degree of parallelism for queries to 4:
EXEC sp_rds_configure N'max degree of parallelism', 4;
blocked process threshold (s)
Specifies the threshold for generating blocked process reports, in seconds. 0 indicates that no blocked process report is generated.
[0, 86400]
0
Immediately effective
Generate a blocked process report when blocking exceeds 20 seconds:
EXEC sp_rds_configure N'blocked process threshold (s)', 20;
default language
Specifies the default language for all newly created login users, with the value being the language ID. Common values: 0 English (US), 30 Simplified Chinese. For the complete list of values, see default language value description.
[0, 33]
0
Immediately effective
Set the default language to Simplified Chinese:
EXEC sp_rds_configure N'default language', 30;
max text repl size (B)
Specifies the maximum number of bytes of text, ntext, varchar(max), nvarchar(max), varbinary(max), image, and xml data that can be copied to a replicated column in a single INSERT, UPDATE, WRITETEXT, or UPDATETEXT operation. -1 indicates no limit.
-1 or [0, 2147483647]
65536
Immediately effective
Set the maximum text replication size to 100 MB:
EXEC sp_rds_configure N'max text repl size (B)', 104857600;
remote login timeout (s)
Specifies the timeout period for waiting for a response after a login request to a remote server is initiated, in seconds. 0 indicates unlimited waiting.
[0, 2147483647]
10
Immediately effective
Set the remote login timeout to 30 seconds:
EXEC sp_rds_configure N'remote login timeout (s)', 30;
remote query timeout (s)
Specifies the waiting time before a remote query (distributed query) is canceled due to timeout, in seconds. 0 indicates unlimited waiting.
[0, 2147483647]
600
Immediately effective
Set the remote query timeout to 60 seconds:
EXEC sp_rds_configure N'remote query timeout (s)', 60;
query wait (s)
Specifies the timeout period for a query waiting for memory grant resources, in seconds. -1 indicates using the default calculated value (25 times the estimated query cost).
-1 or [0, 2147483647]
-1
Immediately effective
Set the timeout for queries waiting for resources to 5 seconds:
EXEC sp_rds_configure N'query wait (s)', 5;
contained database authentication
Specifies whether to allow creating contained databases or modifying existing databases into contained databases. Values: 0 disables it; 1 enables it.
[0, 1]
0
Immediately effective
Enable contained database authentication:
EXEC sp_rds_configure N'contained database authentication', 1;
user options
Specifies the global session default options for all users, with the value being the sum of bitmasks. For the complete list of values, see user options value description.
[0, 32767]
0
Immediately effective
Enable ANSI_NULLS (32) and QUOTED_IDENTIFIER (256) at the same time:
EXEC sp_rds_configure N'user options', 288;
filestream access level
Specifies the FILESTREAM access level for the current instance. Values: 0 disables FILESTREAM; 1 enables Transact-SQL access only. (Note: Streaming access is not supported.)
[0, 1]
0
Immediately effective
Enable Transact-SQL access:
EXEC sp_rds_configure N'filestream access level', 1;
Note:
The value ranges and default values in the table above are based on Microsoft's native definitions. The effective runtime values for an instance can be queried through sys.configurations. For details, see Querying Current Parameter Values.
After modifying the fill factor (%) and user connections parameters, you must manually restart the instance for the changes to take effect. Therefore, after you receive the message "The configure name '{option_name}' need to restart instance to take effected.", restart the instance for the parameter values to take effect. This stored procedure does not automatically restart the instance. Log in to the SQL Server console and manually restart the instance during off-peak hours, and ensure that your application has a reconnection mechanism.

default language Value Description

Value
Language
Value
Language
Value
Language
0
English (American)
12
Czech
24
Estonian
1
German
13
Hungarian
25
Latvian
2
French
14
Polish
26
Lithuanian
3
Japanese
15
Romanian
27
Brazilian Portuguese
4
Danish
16
Croatian
28
Traditional Chinese
5
Spanish
17
Slovak
29
Korean
6
Italian
18
Slovene
30
English
7
Dutch
19
Greek
31
Arabic
8
Norwegian
20
Bulgarian
32
Thai
9
Portuguese
21
Russian
33
Bokmål
10
Finnish
22
Turkish
-
-
11
Swedish
23
English (British)
-
-
Note:
Changes to default language take effect for both new and existing accounts.

user options Value Description

user options is a bitmask. Add the values of the options you want to enable and pass the sum as @config_value. For example, to enable both ANSI_NULLS (32) and QUOTED_IDENTIFIER (256), pass 288.
Attention:
This parameter is a full override, not an incremental enablement.
The passed value will completely replace the current bitmask rather than being appended to it. If the instance currently has a value of 288, directly executing EXEC sp_rds_configure N'user options', 64 will disable both ANSI_NULLS and QUOTED_IDENTIFIER. When adjusting a single option, first execute SELECT value FROM sys.configurations WHERE name = N'user options' to read the current value, then calculate the new value using bitwise OR (to enable) or bitwise AND NOT (to disable) before writing it back.
Value
Option
Description
1
DISABLE_DEF_CNST_CHK
Controls deferred or immediate constraint checking. Deprecated and not recommended.
2
IMPLICIT_TRANSACTIONS
After a statement is executed, if the transaction is not explicitly committed or rolled back, an implicit transaction is automatically started. This applies only to DB-Library network library connections and has no effect on ODBC or OLE DB connections.
4
CURSOR_CLOSE_ON_COMMIT
Automatically closes opened cursors after a transaction is committed.
8
ANSI_WARNINGS
Issues warnings for conditions such as Null values in aggregates, string truncation, and division by zero.
16
ANSI_PADDING
Controls the padding behavior of trailing spaces and zeros in fixed-length and variable-length data type columns.
32
ANSI_NULLS
Follows the ISO standard when equal to (=) or not equal to (<>) comparisons are used on Null values.
64
ARITHABORT
Terminates the query when an overflow or division-by-zero error occurs during query execution.
128
ARITHIGNORE
Returns Null instead of reporting an error when an overflow or division-by-zero error occurs during query execution.
256
QUOTED_IDENTIFIER
Allows identifiers to be delimited by double quotation marks.
512
NOCOUNT
Disables the message that returns the number of affected rows after a statement is executed.
1024
ANSI_NULL_DFLT_ON
New columns for which nullability is not explicitly specified allow Null values by default.
2048
ANSI_NULL_DFLT_OFF
New columns for which nullability is not explicitly specified do not allow Null values by default.
4096
CONCAT_NULL_YIELDS_NULL
Returns Null when a string is concatenated with a Null value.
8192
NUMERIC_ROUNDABORT
Generates an error when a loss of precision occurs in an expression.
16384
XACT_ABORT
Rolls back the entire transaction when a statement causes a runtime error.
Attention:
ANSI_NULL_DFLT_ON (1024) and ANSI_NULL_DFLT_OFF (2048) are mutually exclusive and cannot be set at the same time.
The bit order of user options is consistent with @@OPTIONS. After modification, the change takes effect only for new sessions, and currently connected sessions are not affected.
Clients can override the default value set here by using the SET statement, so this parameter only affects sessions that have not explicitly set it.

Returned values

Return Code
Meaning
0
Successful
Non-zero
Failed

Call Example

Modifying a Single Parameter

-- Set the index page fill factor to 90% (instance restart required for the change to take effect)
EXEC sp_rds_configure @config_name = N'fill factor (%)', @config_value = 90
GO

-- Set the parallel cost threshold to 30
EXEC sp_rds_configure @config_name = N'cost threshold for parallelism', @config_value = 30
GO

-- Set the maximum degree of parallelism for queries to 4
EXEC sp_rds_configure @config_name = N'max degree of parallelism', @config_value = 4
GO

-- Set the blocked process report threshold to 20 seconds
EXEC sp_rds_configure @config_name = N'blocked process threshold (s)', @config_value = 20
GO

-- Set the default language for newly created logins to Simplified Chinese
EXEC sp_rds_configure @config_name = N'default language', @config_value = 30
GO

-- Set the maximum text size for replication to 100 MB
EXEC sp_rds_configure @config_name = N'max text repl size (B)', @config_value = 104857600
GO

-- Set the remote login timeout to 30 seconds
EXEC sp_rds_configure @config_name = N'remote login timeout (s)', @config_value = 30
GO

-- Set the remote query timeout to 60 seconds
EXEC sp_rds_configure @config_name = N'remote query timeout (s)', @config_value = 60
GO

-- Set the timeout for queries waiting for resources to 5 seconds
EXEC sp_rds_configure @config_name = N'query wait (s)', @config_value = 5
GO

-- Enable contained database authentication
EXEC sp_rds_configure @config_name = N'contained database authentication', @config_value = 1
GO

-- Enable both ANSI_NULLS (32) and QUOTED_IDENTIFIER (256)
EXEC sp_rds_configure @config_name = N'user options', @config_value = 288
GO

-- Enable Transact-SQL access to FILESTREAM
EXEC sp_rds_configure @config_name = N'filestream access level', @config_value = 1
GO

Calling with Positional Parameters

You can also omit parameter names and pass values in positional order:
EXEC sp_rds_configure N'max worker threads', 1000
GO

Receiving Return Codes

DECLARE @ret INT

EXEC @ret = sp_rds_configure
@config_name = N'max degree of parallelism',
@config_value = 8

IF @ret = 0
PRINT N'Parameter settings succeeded'
ELSE
PRINT N'Parameter settings failed. Return code: ' + CAST(@ret AS NVARCHAR(10))
GO

Querying Current Parameter Values

After the modification, you can verify whether the parameter has taken effect by querying sys.configurations:
SELECT name AS [parameter item],
value AS [configuration value],
value_in_use AS [runtime value],
is_dynamic AS [whether restart is required],
minimum AS [minimum value],
maximum AS [maximum value],
description AS [description]
FROM sys.configurations
WHERE name IN (
N'fill factor (%)'
,N'max worker threads'
,N'user connections'
,N'remote proc trans'
,N'cost threshold for parallelism'
,N'max degree of parallelism'
,N'blocked process threshold (s)'
,N'default language'
,N'max text repl size (B)'
,N'remote login timeout (s)'
,N'remote query timeout (s)'
,N'query wait (s)'
,N'contained database authentication'
,N'user options'
,N'filestream access level'
)
ORDER BY name
value is the configured value, and value_in_use is the current running value.
If value differs from value_in_use and is_dynamic = 0, the parameter takes effect only after the instance is restarted.
Query the parameter items that are configured but have not yet taken effect:
SELECT name, value, value_in_use
FROM sys.configurations
WHERE value <> value_in_use

Note

No need to manually enable advanced options: The parameter items in the preceding table that belong to Microsoft "advanced options" (such as max worker threads, max degree of parallelism, and query wait (s)) are already handled inside the stored procedure, so you do not need to execute sp_configure 'show advanced options', 1.
Automatic primary/secondary synchronization: After a parameter is modified on a two-node or multi-node instance, it is automatically synchronized to the secondary node, so no reconfiguration is required after a primary/secondary switchover.
Read-only instance parameters: Parameters for read-only instances must be configured separately.
Some parameters require a restart: After modifying fill factor (%) and user connections, you must manually restart the instance for the changes to take effect. Therefore, after you receive the message "The configure name '{option_name}' need to restart instance to take effected.", restart the instance for the parameter values to take effect. Perform the operation during off-peak hours, and ensure that your application has a reconnection mechanism.
May trigger recompilation: Modifying optimizer-related parameters such as max degree of parallelism and cost threshold for parallelism invalidates execution plans in the plan cache and causes recompilation. This may lead to a short-term increase in CPU usage. Perform the operation during off-peak hours.
Adjust concurrency and thread parameters with caution: Setting max worker threads and user connections too low may cause connections to be rejected or requests to be queued. Keep the default value 0 (automatically managed by SQL Server) unless adjustment is necessary.
remote proc trans has been marked as deprecated by Microsoft: This parameter may be removed in future SQL Server versions, so it is not recommended for new workloads.

Ajuda e Suporte

Esta página foi útil?

comentários