> For the complete documentation index, see [llms.txt](https://kythuat.dtechvn.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://kythuat.dtechvn.com/sql-server/che-do-xp_cmd-shell-trong-sql-server.md).

# 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>
