# Chế độ xp\_cmd shell trong SQL Server

## DÙNG LỆNH T-SQL

**Kiểm tra trạng thái**

```sql
SELECT CONVERT(INT, ISNULL(value, value_in_use)) AS ConfigValue
FROM sys.configurations
WHERE name = 'xp_cmdshell' ;
```

**Bật sử dụng:**

```sql
-- Enable advanced options to be changed.
EXEC SP_CONFIGURE 'show advanced options', 1
GO
RECONFIGURE
GO
-- Enable xp_cmdshell option.
EXEC SP_CONFIGURE N'xp_cmdshell', 1
GO
RECONFIGURE
GO
```

**Tắt sử dụng:**

```sql
-- Disable xp_cmdshell option. 
EXEC SP_CONFIGURE 'xp_cmdshell', 0
GO
RECONFIGURE
GO
-- Disable advanced options to be changed.
EXEC SP_CONFIGURE 'show advanced options', 0
GO
RECONFIGURE
GO
```

## DÙNG MANAGER STUDIO

<figure><img src="/files/Ol7Y4Vj8vR8fptOplUke" alt=""><figcaption></figcaption></figure>

<figure><img src="/files/FKrznrr1udtEe3f6b80G" alt=""><figcaption></figcaption></figure>


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://kythuat.dtechvn.com/sql-server/che-do-xp_cmd-shell-trong-sql-server.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
